diagrams-lib-1.4.2.3: Embedded domain-specific language for declarative graphics

Copyright | (c) 2011 diagrams-lib team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.TwoD.Image

Description

Importing external images into diagrams. Usage example: To create a diagram from an embedded image with width 1 and height set according to the aspect ratio, use `image img # scaleUToX 1`, where `img` is a value of type `DImage n e`, created with a function like `loadImageEmb`, `loadImageExt`, or `raster`.

Synopsis

- data DImage :: * -> * -> * where
  - DImage :: ImageData t -> Int -> Int -> Transformation V2 n -> DImage n t
- data ImageData :: * -> * where
  - ImageRaster :: DynamicImage -> ImageData Embedded
  - ImageRef :: FilePath -> ImageData External
  - ImageNative :: t -> ImageData (Native t)
- data Embedded
- data External
- data Native (t :: *)
- image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any
- embeddedImage :: Num n => DynamicImage -> DImage n Embedded
- loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded))
- loadImageEmbBS :: Num n => ByteString -> Either String (DImage n Embedded)
- loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External))
- uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External
- raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded
- rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any

# Documentation

data DImage :: * -> * -> * where Source #

An image primitive, the two ints are width followed by height. Will typically be created by `loadImageEmb` or `loadImageExt` which, will handle setting the width and height to the actual width and height of the image.

Constructors

DImage :: ImageData t -> Int -> Int -> Transformation V2 n -> DImage n t |

Instances

Fractional n => Transformable (DImage n a) Source # |
Instance details Defined in Diagrams.TwoD.Image Methods transform :: Transformation (V (DImage n a)) (N (DImage n a)) -> DImage n a -> DImage n a Source #
Fractional n => HasOrigin (DImage n a) Source # |
Instance details Defined in Diagrams.TwoD.Image Methods moveOriginTo :: Point (V (DImage n a)) (N (DImage n a)) -> DImage n a -> DImage n a Source #
Fractional n => Renderable (DImage n a) NullBackend Source # |
Instance details Defined in Diagrams.TwoD.Image Methods render :: NullBackend -> DImage n a -> Render NullBackend (V (DImage n a)) (N (DImage n a)) Source #
RealFloat n => HasQuery (DImage n a) Any Source # |
Instance details Defined in Diagrams.TwoD.Image Methods getQuery :: DImage n a -> Query (V (DImage n a)) (N (DImage n a)) Any Source #
type V (DImage n a) Source # |
Instance details Defined in Diagrams.TwoD.Image type V (DImage n a) = V2
type N (DImage n a) Source # |
Instance details Defined in Diagrams.TwoD.Image type N (DImage n a) = n

data ImageData :: * -> * where Source #

`ImageData` is either a JuicyPixels `DynamicImage` tagged as `Embedded` or a reference tagged as `External`. Additionally `Native` is provided for external libraries to hook into.

Constructors

ImageRaster :: DynamicImage -> ImageData Embedded |
ImageRef :: FilePath -> ImageData External |
ImageNative :: t -> ImageData (Native t) |

data Embedded Source #

data External Source #

data Native (t :: *) Source #

image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any Source #

Make a `DImage` into a `Diagram`.

embeddedImage :: Num n => DynamicImage -> DImage n Embedded Source #

Read a JuicyPixels `DynamicImage` and wrap it in a `DImage`. The width and height of the image are set to their actual values.

loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded)) Source #

Use JuicyPixels to read a file in any format and wrap it in a `DImage`. The width and height of the image are set to their actual values.

loadImageEmbBS :: Num n => ByteString -> Either String (DImage n Embedded) Source #

A pure variant of `loadImageEmb`

loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External)) Source #

Check that a file exists, and use JuicyPixels to figure out the right size, but save a reference to the image instead of the raster data

uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External Source #

Make an "unchecked" image reference; have to specify a width and height. Unless the aspect ratio of the external image is the w :: h, then the image will be distorted.

raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded Source #

Create an image "from scratch" by specifying the pixel data

rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any Source #

Crate a diagram from raw raster data.