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

Copyright(c) 2011 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.TwoD.Image

Description

Importing external images into diagrams. Usage: To create a diagram from an embedded image with width 1 and height set according to the aspect ratio: 'image img # scaleUToX 1` where img is a 'DImage Embedded'

Synopsis

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 heigh to the actual width and height of the image.

Constructors

DImage :: ImageData t -> Int -> Int -> T2 -> DImage t 

Instances

data ImageData :: * -> * where Source

ImageData is either a JuicyPixels DynamicImage tagged as Embedded or a reference tagged as External.

data Embedded Source

Instances

data External Source

Instances

image :: (Typeable a, Renderable (DImage a) b) => DImage a -> Diagram b R2 Source

Make a DImage into a Diagram.

loadImageEmb :: FilePath -> IO (Either String (DImage Embedded)) Source

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

loadImageExt :: FilePath -> IO (Either String (DImage 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 :: FilePath -> Int -> Int -> DImage 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 :: (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage Embedded Source

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

rasterDia :: Renderable (DImage Embedded) b => (Int -> Int -> AlphaColour Double) -> Int -> Int -> Diagram b R2 Source

Crate a diagram from raw raster data.