| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Miso.Svg
Description
Render geometric objects to Svg files through miso
Synopsis
- renderSvgToFile :: OsPath -> View () () () action -> IO ()
- renderAsSvgText :: View () () () action -> Text
- renderAsSvgByteString :: View () () () action -> ByteString
- withAts :: ([Attribute model action] -> View context props model action) -> [Attribute model action] -> [Attribute model action] -> View context props model action
- class Drawable t where
- dPoint :: (Point_ point 2 r, ToMisoString r) => point -> [Attribute model action] -> View context props model action
- dLineSegment :: (LineSegment_ lineSegment point, Point_ point 2 r, ToMisoString r) => lineSegment -> [Attribute model action] -> View context props model action
- dRectangle :: (Rectangle_ rectangle point, Point_ point 2 r, ToMisoString r, Num r) => rectangle -> [Attribute model action] -> View context props model action
- dCircle :: (Point_ point 2 r, ToMisoString r, Radical r) => Circle point -> [Attribute model action] -> View context props model action
- dDisk :: (Disk_ disk point, ConstructableBall_ disk point, Point_ point 2 r, ToMisoString r, Radical r) => disk -> [Attribute model action] -> View context props model action
- dPolyLine :: (PolyLine_ polyLine point, Point_ point 2 r, ToMisoString r) => polyLine -> [Attribute model action] -> View context props model action
- dSimplePolygon :: (SimplePolygon_ simplePolygon point r, ToMisoString r) => simplePolygon -> [Attribute model action] -> View context props model action
- class SvgWriteAttributes (ats :: (Type -> Type) -> Type) action where
- svgAttrFunctions :: ats (SvgF action)
- svgAttrDefaults :: ats (AttrList action :: Type -> Type)
- svgWriteAttrs :: ats Maybe -> [Attribute model action]
Documentation
renderSvgToFile :: OsPath -> View () () () action -> IO () Source #
Given an file path, and a view whose root is an svg element, render the output to the given file.
renderAsSvgText :: View () () () action -> Text Source #
Given an View whose root is an svg element, renders the view to a lazy Text
renderAsSvgByteString :: View () () () action -> ByteString Source #
Given an View whose root is an svg element, renders the view to a lazy ByteString.
withAts :: ([Attribute model action] -> View context props model action) -> [Attribute model action] -> [Attribute model action] -> View context props model action Source #
Helper function to construct drawing functions. I..e it allows you do pre-specify a bunch of attributes that should be drawn (ats1) yet allow more attributes to be added by the user later.
class Drawable t where Source #
Methods
draw :: t -> [Attribute model action] -> View context props model action Source #
Draws the given object with the given attributes
drawWith :: t -> [Attribute model action] -> [View context props model action] -> View context props model action Source #
draw the given object, as well as the given "children"
Instances
dPoint :: (Point_ point 2 r, ToMisoString r) => point -> [Attribute model action] -> View context props model action Source #
Draw a point
dLineSegment :: (LineSegment_ lineSegment point, Point_ point 2 r, ToMisoString r) => lineSegment -> [Attribute model action] -> View context props model action Source #
Draw a line segment
dRectangle :: (Rectangle_ rectangle point, Point_ point 2 r, ToMisoString r, Num r) => rectangle -> [Attribute model action] -> View context props model action Source #
Draw a rectangle
dCircle :: (Point_ point 2 r, ToMisoString r, Radical r) => Circle point -> [Attribute model action] -> View context props model action Source #
Draw a circle
dDisk :: (Disk_ disk point, ConstructableBall_ disk point, Point_ point 2 r, ToMisoString r, Radical r) => disk -> [Attribute model action] -> View context props model action Source #
Draw a disk
dPolyLine :: (PolyLine_ polyLine point, Point_ point 2 r, ToMisoString r) => polyLine -> [Attribute model action] -> View context props model action Source #
Draw a polyline
dSimplePolygon :: (SimplePolygon_ simplePolygon point r, ToMisoString r) => simplePolygon -> [Attribute model action] -> View context props model action Source #
Draw a simple polygon
class SvgWriteAttributes (ats :: (Type -> Type) -> Type) action where Source #
Minimal complete definition
Methods
svgAttrFunctions :: ats (SvgF action) Source #
The functions that specify how to write the values to attributes
svgAttrDefaults :: ats (AttrList action :: Type -> Type) Source #
The attribute values we are using if the attribute is set to Nothing.
This is particularly useful for e.g. fill. If there is no fill color set,
we should add a 'fill=none.
default svgAttrDefaults :: ApplicativeB ats => ats (AttrList action :: Type -> Type) Source #
svgWriteAttrs :: ats Maybe -> [Attribute model action] Source #
Write the actual attributes
default svgWriteAttrs :: (ApplicativeB ats, TraversableB ats) => ats Maybe -> [Attribute model action] Source #