Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Graphic
- drawGraphic :: Graphic -> Point -> Picture ()
- graphicBounds :: Graphic -> Rect
- inGraphic :: Point -> Graphic -> Bool
- noGraphic :: Graphic
- inRect :: Point -> Rect -> Bool
- measureText :: TextStyle -> JSString -> Double
- pixelRatio :: Double
- type Point = (Double, Double)
- data Rect = Rect Double Double Double Double
- data Color = RGBA Double Double Double Double
- data PathStyle = PathStyle {}
- data TextStyle = TextStyle {}
- data Canvas :: *
- data Picture a :: * -> *
- render :: MonadIO m => Canvas -> Picture a -> m a
- getCanvas :: MonadIO m => Elem -> m (Maybe Canvas)
Type
The Graphic type
QuadraticPath PathStyle Point [(Point, Point)] | A path made up of quadratic Bezier curves, start point + (control point, end point) list. |
Text TextStyle Point JSString | Text string, point indicates top left of text bounding box |
BlankGraphic Rect | Invisible graphic which takes up space. Useful for e.g. a spacer. |
Functions
drawGraphic :: Graphic -> Point -> Picture () Source
Draw a graphic to a canvas, with the given point as the top left
graphicBounds :: Graphic -> Rect Source
Find a rectangle that contains the entire graphic
inGraphic :: Point -> Graphic -> Bool Source
Determine if a point is inside a graphic.
A point is considered inside a text string if it is within the rectangle defined by the line height and width of the text.
A point is considered inside a path if a ray from the point directly to the left crosses the path an odd number of times. This works as expected for closed non-intersecting paths.
measureText :: TextStyle -> JSString -> Double Source
Auxiliary Types
type Point = (Double, Double) Source
A point, represented as (x,y); following browser convention, positive x points right and positive y points downward.
An RGBA color, each number should be between 0 and 1. Future version will include gradients.
Determines how a path is drawn. Stroke includes width as well as color.
Determines how a text string is drawn to the canvas.
Re-exported
data Canvas :: *
A canvas; a viewport into which a picture can be rendered. The origin of the coordinate system used by the canvas is the top left corner of the canvas element. JS representation is a reference to the backing canvas element.
data Picture a :: * -> *
A picture that can be drawn onto a canvas.