diagrams-lib-1.3.1.1: 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 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

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

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.

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.

loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n 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 :: 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.