dia-base-0.1.1.3: An EDSL for teaching Haskell with diagrams - data types

Safe HaskellSafe
LanguageHaskell98

Graphics.Diagrams

Contents

Description

Diagrams user API

Synopsis

Points

type Point = (Double, Double)

Point type as defined in the diagrams package

(*.) :: Double -> Point -> Point infixl 7

Scalar multiplication.

(.*.) :: Point -> Point -> Point infixl 7

Elementwise addition, subtraction and multiplication for Points.

(.+.) :: Point -> Point -> Point infixl 6

Elementwise addition, subtraction and multiplication for Points.

(.-.) :: Point -> Point -> Point infixl 6

Elementwise addition, subtraction and multiplication for Points.

Colors

data Color

colors

color :: String -> Color

named color

rgb :: Double -> Double -> Double -> Color

RGB color (components are between 0 and 1)

Diagrams

data Diagram

Diagram data type

Instances

Primitives

empty :: Diagram

empty diagram

rect :: Double -> Double -> Diagram

rectangle given with width and height

rectangle :: Point -> Point -> Diagram

rectangle given with two opposite corners

circle :: Double -> Diagram

circle with radius

(>-<) :: Point -> Point -> Diagram infix 4

line segment

(~~) :: Point -> Point -> Diagram infix 4

line segment

Texts

textFrom :: String -> Point -> Diagram infixl 3

text; beginning of text is fixed

textTo :: String -> Point -> Diagram infixl 3

text; end of text is fixed

textAt :: String -> Point -> Diagram infixl 3

text; middle of text is fixed

Transformations

move :: Diagram -> Point -> Diagram infixl 3

rotate :: Diagram -> Double -> Diagram infixl 3

rotate (degree)

scale :: Diagram -> Double -> Diagram infixl 3

scale differently at x and y axes

scaleXY :: Diagram -> (Double, Double) -> Diagram infixl 3

clip :: Point -> Point -> Diagram -> Diagram

clip a rectangle region (give lower-left and upper-right corners)

Styles

fill :: Diagram -> Color -> Diagram infixl 3

fill with color

stroke :: Diagram -> Color -> Diagram infixl 3

set stroke color

strokeWidth :: Diagram -> Double -> Diagram infixl 3

set stroke width

fontFamily :: Diagram -> String -> Diagram infixl 3

set font family

link :: Diagram -> String -> Diagram infixl 3

add an html link

Combining diagrams

(<|>) :: Diagram -> Diagram -> Diagram infixl 2

overlay; the second diagram is over the first one

union :: [Diagram] -> Diagram

overlay generalized to several diagrams

pack :: Diagram -> (Diagram -> Diagram) -> Diagram

pack a diagram; (pack d f) is the more efficient version of (let v=d in f v).