Safe Haskell | None |
---|---|
Language | Haskell2010 |
The module was originally inspired by gloss Picture data type.
It allows you to define simple pieces, combine and move/rotate/scale them to produce the final image.
Example of composite picture (filled circle inside stroked one, both moved to the side by 50 pixels):
translateP 50 0 $ pictures [ fill (NVG.Color 1 1 1 1) $ circle (10, 10) 10 , stroke (NVG.Color 1 1 1 1) $ circle (10, 10) 15 ]
Synopsis
- newtype Shape = Shape {}
- type Radius = Float
- type Point = (Float, Float)
- type Center = Point
- type Angle = Float
- circle :: Center -> Radius -> Shape
- line :: Point -> Point -> Shape
- rectangle :: Point -> Point -> Shape
- arc :: Center -> Radius -> Angle -> Angle -> Shape
- shapes :: [Shape] -> Shape
- translateS :: Float -> Float -> Shape -> Shape
- rotateS :: Center -> Angle -> Shape -> Shape
- scaleS :: Center -> Angle -> Float -> Shape -> Shape
- scaleS' :: Center -> Float -> Shape -> Shape
- scaleSx :: Center -> Float -> Shape -> Shape
- scaleSy :: Center -> Float -> Shape -> Shape
- hole :: Shape -> Shape
- data Picture
- mapShape :: (Shape -> Shape) -> Picture -> Picture
- stroke :: Color -> Shape -> Picture
- fill :: Color -> Shape -> Picture
- pictures :: [Picture] -> Picture
- translateP :: Float -> Float -> Picture -> Picture
- rotateP :: Center -> Angle -> Picture -> Picture
- scaleP :: Center -> Angle -> Float -> Picture -> Picture
- scaleP' :: Center -> Float -> Picture -> Picture
- scalePx :: Center -> Float -> Picture -> Picture
- scalePy :: Center -> Float -> Picture -> Picture
- render :: Context -> Picture -> IO ()
- asWindow :: IO Picture -> Window ()
Shapes
Shape of a future picture fragment, to be filled or stroked later.
Action should define set of paths for the passed Context
.
Helper type aliases
Predefined Constructors
rectangle :: Point -> Point -> Shape Source #
Make rectangular shape given two (opposite) corners positions.
arc :: Center -> Radius -> Angle -> Angle -> Shape Source #
Make arc shape with given center and going counter-clockwise from first angle to the second.
rotateS :: Center -> Angle -> Shape -> Shape Source #
Rotate shape around given point by given angle.
scaleS :: Center -> Angle -> Float -> Shape -> Shape Source #
Scale shape from given point in given direction. This is affine transformation
scaleS' :: Center -> Float -> Shape -> Shape Source #
Scale shape from given point by given factor in every direction.
scaleSx :: Center -> Float -> Shape -> Shape Source #
Scale shape from given point in positive X direction by given factor.
scaleSy :: Center -> Float -> Shape -> Shape Source #
Scale shape from given point in positive Y direction by given factor.
hole :: Shape -> Shape Source #
Turns shape into a hole which can then be combined with other (solid) shape. E.g.
fill (Color 1 0 0 1) $ shapes [circle (0, 0) 40, hole $ circle (0, 0) 30]
can be used to create a ring of width 10.
Pictures
mapShape :: (Shape -> Shape) -> Picture -> Picture Source #
Modify shape(s) the picture was based off.
Contstructors
Pictures are generally constructed by filling or stroking shape or by transforming exising picture.
translateP :: Float -> Float -> Picture -> Picture Source #
Translate the picture by given x
and y
offsets.
rotateP :: Center -> Angle -> Picture -> Picture Source #
Rotate the picture around given point for given angle.
scaleP :: Center -> Angle -> Float -> Picture -> Picture Source #
Scale picture from given point in given direction. This is affine transformation
scaleP' :: Center -> Float -> Picture -> Picture Source #
Scale picture from given point by given factor in every direction.
scalePx :: Center -> Float -> Picture -> Picture Source #
Scale picture from given point in positive X direction by given factor.
scalePy :: Center -> Float -> Picture -> Picture Source #
Scale picture from given point in positive Y direction by given factor.