hgeometry-svg
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2024

HGeometry.Miso.Svg

Description

Render geometric objects to Svg files through miso

Synopsis

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 #

Minimal complete definition

draw | drawWith

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

Instances details
ToMisoString r => Drawable (Group r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Group r -> [Attribute model action] -> View context props model action Source #

drawWith :: Group r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (Image r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Image r -> [Attribute model action] -> View context props model action Source #

drawWith :: Image r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (IpeObject r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: IpeObject r -> [Attribute model action] -> View context props model action Source #

drawWith :: IpeObject r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (IpeSymbol r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: IpeSymbol r -> [Attribute model action] -> View context props model action Source #

drawWith :: IpeSymbol r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (MiniPage r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: MiniPage r -> [Attribute model action] -> View context props model action Source #

drawWith :: MiniPage r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (TextLabel r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: TextLabel r -> [Attribute model action] -> View context props model action Source #

drawWith :: TextLabel r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (Path r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Path r -> [Attribute model action] -> View context props model action Source #

drawWith :: Path r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (PathSegment r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: PathSegment r -> [Attribute model action] -> View context props model action Source #

drawWith :: PathSegment r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, Radical r, ToMisoString r) => Drawable (Circle point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Circle point -> [Attribute model action] -> View context props model action Source #

drawWith :: Circle point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, ToMisoString r, Radical r) => Drawable (Disk point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Disk point -> [Attribute model action] -> View context props model action Source #

drawWith :: Disk point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, ToMisoString r, Num r) => Drawable (Rectangle point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Rectangle point -> [Attribute model action] -> View context props model action Source #

drawWith :: Rectangle point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Drawable l, Drawable r) => Drawable (Either l r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Either l r -> [Attribute model action] -> View context props model action Source #

drawWith :: Either l r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Drawable g, ToMisoString r, forall action. SvgWriteAttributes (ats r) action) => Drawable (g :+ ats r Maybe) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: (g :+ ats r Maybe) -> [Attribute model action] -> View context props model action Source #

drawWith :: (g :+ ats r Maybe) -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, EndPoint_ (endPoint point), IxValue (endPoint point) ~ point, ToMisoString r) => Drawable (LineSegment endPoint point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: LineSegment endPoint point -> [Attribute model action] -> View context props model action Source #

drawWith :: LineSegment endPoint point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

ToMisoString r => Drawable (Point 2 r) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: Point 2 r -> [Attribute model action] -> View context props model action Source #

drawWith :: Point 2 r -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, ToMisoString r, Traversable1 f, Ixed (f point), IxValue (f point) ~ point, Index (f point) ~ Int, HasFromFoldable1 f, TraversableWithIndex Int f) => Drawable (PolyLineF f point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: PolyLineF f point -> [Attribute model action] -> View context props model action Source #

drawWith :: PolyLineF f point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, VertexContainer f point, HasFromFoldable1 f, ToMisoString r) => Drawable (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: ConvexPolygonF f point -> [Attribute model action] -> View context props model action Source #

drawWith :: ConvexPolygonF f point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

(Point_ point 2 r, VertexContainer f point, HasFromFoldable1 f, ToMisoString r) => Drawable (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

draw :: SimplePolygonF f point -> [Attribute model action] -> View context props model action Source #

drawWith :: SimplePolygonF f point -> [Attribute model action] -> [View context props model action] -> View context props model action Source #

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

svgAttrFunctions

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 #

Instances

Instances details
SvgWriteAttributes (CommonAttributes r) action Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

svgAttrFunctions :: CommonAttributes r (SvgF action) Source #

svgAttrDefaults :: CommonAttributes r (AttrList action :: Type -> Type) Source #

svgWriteAttrs :: CommonAttributes r Maybe -> [Attribute model action] Source #

SvgWriteAttributes (GroupAttributesF r) action Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

svgAttrFunctions :: GroupAttributesF r (SvgF action) Source #

svgAttrDefaults :: GroupAttributesF r (AttrList action :: Type -> Type) Source #

svgWriteAttrs :: GroupAttributesF r Maybe -> [Attribute model action] Source #

ToMisoString r => SvgWriteAttributes (PathAttributesF r) action Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

svgAttrFunctions :: PathAttributesF r (SvgF action) Source #

svgAttrDefaults :: PathAttributesF r (AttrList action :: Type -> Type) Source #

svgWriteAttrs :: PathAttributesF r Maybe -> [Attribute model action] Source #

ToMisoString r => SvgWriteAttributes (SymbolAttributesF r) action Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

ToMisoString r => SvgWriteAttributes (TextAttributesF r) action Source # 
Instance details

Defined in HGeometry.Miso.Svg.Writer

Methods

svgAttrFunctions :: TextAttributesF r (SvgF action) Source #

svgAttrDefaults :: TextAttributesF r (AttrList action :: Type -> Type) Source #

svgWriteAttrs :: TextAttributesF r Maybe -> [Attribute model action] Source #