| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
Ipe.IpeOut
Description
Functions that help drawing geometric values in ipe. An IpeOut is essenitally a function that converts a geometric type g into an IpeObject.
We also proivde a HasDefaultIpeOut typeclass that defines a default conversion function from a geometry type g to an ipe type.
Synopsis
- type IpeOut g (i :: Type -> Type) r = g -> IpeObject' i r
- type IpeOut' (f :: Type -> Type) g (i :: Type -> Type) r = g -> f (IpeObject' i r)
- (!) :: IpeObject' i r -> IpeAttributes i r -> IpeObject' i r
- iO :: ToObject i => IpeObject' i r -> IpeObject r
- iO'' :: forall g r (i :: Type -> Type). (HasDefaultIpeOut g, NumType g ~ r, DefaultIpeOut g ~ i, ToObject i) => g -> IpeAttributes i r -> IpeObject r
- iO' :: HasDefaultIpeOut g => g -> IpeObject (NumType g)
- class ToObject (DefaultIpeOut g) => HasDefaultIpeOut g where
- type DefaultIpeOut g :: Type -> Type
- defIO :: IpeOut g (DefaultIpeOut g) (NumType g)
- ipeMark :: Text -> IpeOut (Point 2 r) IpeSymbol r
- ipeDiskMark :: IpeOut (Point 2 r) IpeSymbol r
- defaultBox :: Num r => Rectangle (Point 2 r)
- ipeLine :: (Ord r, Fractional r, Show r) => IpeOut (LinePV 2 r) Path r
- ipeLineIn :: (Ord r, Fractional r, Show r) => Rectangle (Point 2 r) -> IpeOut (LinePV 2 r) Path r
- ipeHalfLine :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => IpeOut (HalfLine point) Path r
- ipeRay :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => IpeOut (HalfLine point) Path r
- ipeHalfLineIn :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => Rectangle point -> IpeOut (HalfLine point) Path r
- ipeLineSegment :: (LineSegment_ lineSegment point, Point_ point 2 r) => IpeOut lineSegment Path r
- ipePolyLine :: IpeOut (PolyLine (Point 2 r)) Path r
- ipeEllipse :: IpeOut (Ellipse r) Path r
- ipeCircle :: Radical r => IpeOut (Circle (Point 2 r)) Path r
- ipeDisk :: Radical r => IpeOut (Disk (Point 2 r)) Path r
- ipeBezier :: IpeOut (CubicBezier (Point 2 r)) Path r
- path :: PathSegment r -> Path r
- pathSegment :: (LineSegment_ lineSegment point, Point_ point 2 r) => lineSegment -> PathSegment r
- ipePolygon :: Polygon_ polygon point r => IpeOut polygon Path r
- toPolygonPathSegment :: (HasOuterBoundary polygon, Point_ point 2 r, Vertex polygon ~ point) => polygon -> PathSegment r
- ipeSimplePolygon :: SimplePolygon_ simplePolygon point r => IpeOut simplePolygon Path r
- ipeSimplePolygon' :: forall (f :: Type -> Type) r. Foldable1 f => IpeOut (SimplePolygonF f (Point 2 r)) Path r
- review' :: Prism s t a b -> b -> t
- ipeRectangle :: Num r => IpeOut (Rectangle (Point 2 r)) Path r
- ipeTriangle :: (Eq r, Num r) => IpeOut (Triangle (Point 2 r)) Path r
- ipeHalfPlane :: (Show r, Fractional r, Ord r) => IpeColor r -> IpeOut (HalfSpaceF (LinePV 2 r)) Group r
- ipeHalfPlaneIn :: (Ord r, Fractional r, Show r) => Rectangle (Point 2 r) -> IpeColor r -> IpeOut (HalfSpaceF (LinePV 2 r)) Group r
- ipeGroup :: Foldable f => IpeOut (f (IpeObject r)) Group r
- type InlineLaTeX = Text
- ipeLabel :: IpeOut (InlineLaTeX :+ Point 2 r) TextLabel r
- labelled :: (Show lbl, NumType g ~ r, ToObject i) => (g -> Point 2 r) -> IpeOut g i r -> IpeOut (g :+ lbl) Group r
- labelledWith :: (Show lbl, NumType g ~ r, ToObject i) => IpeAttributes TextLabel r -> (g -> Point 2 r) -> IpeOut g i r -> IpeOut (g :+ lbl) Group r
- toInlineLatex :: Text -> InlineLaTeX
Documentation
>>>:seti -XOverloadedStrings>>>:{let Just (myPolygon :: SimplePolygon (Point 2 Int)) = fromPoints $ [origin, Point2 10 10, Point2 100 200] :}
The IpeOut type and the default combinator to use it
type IpeOut g (i :: Type -> Type) r = g -> IpeObject' i r Source #
an IpeOut is just a function that can construct an appropriate IpeObject'
type IpeOut' (f :: Type -> Type) g (i :: Type -> Type) r = g -> f (IpeObject' i r) Source #
Give the option to draw zero, one or more things, i.e. by choosing f ~ Maybe or f ~ []
(!) :: IpeObject' i r -> IpeAttributes i r -> IpeObject' i r Source #
Add attributes to an IpeObject'
iO :: ToObject i => IpeObject' i r -> IpeObject r Source #
Render an ipe object
>>>:{iO $ defIO myPolygon ! attr SFill (IpeColor "blue") ! attr SLayer "alpha" ! attr SLayer "beta" :} IpePath (Path {_pathSegments = fromList [PolygonPath AsIs (SimplePolygon [Point2 0 0,Point2 10 10,Point2 100 200])]} :+ Attrs {Attr LayerName {_layerName = "beta"}, NoAttr, NoAttr, NoAttr, NoAttr, Attr IpeColor (Named "blue"), NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr})
>>>:{iO $ ipeGroup [ iO $ ipePolygon myPolygon ! attr SFill (IpeColor "red") ] ! attr SLayer "alpha" :} IpeGroup (Group [IpePath (Path {_pathSegments = fromList [PolygonPath AsIs (SimplePolygon [Point2 0 0,Point2 10 10,Point2 100 200])]} :+ Attrs {NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, Attr IpeColor (Named "red"), NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr})] :+ Attrs {Attr LayerName {_layerName = "alpha"}, NoAttr, NoAttr, NoAttr, NoAttr})
iO'' :: forall g r (i :: Type -> Type). (HasDefaultIpeOut g, NumType g ~ r, DefaultIpeOut g ~ i, ToObject i) => g -> IpeAttributes i r -> IpeObject r Source #
Render to an ipe object using the defIO IpeOut
>>>:{iO'' myPolygon $ attr SFill (IpeColor "red") <> attr SLayer "alpha" <> attr SLayer "beta" :} IpePath (Path {_pathSegments = fromList [PolygonPath AsIs (SimplePolygon [Point2 0 0,Point2 10 10,Point2 100 200])]} :+ Attrs {Attr LayerName {_layerName = "beta"}, NoAttr, NoAttr, NoAttr, NoAttr, Attr IpeColor (Named "red"), NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr})
>>>iO'' [ myPolygon , myPolygon ] $ attr SLayer "alpha"IpeGroup (Group [IpePath (Path {_pathSegments = fromList [PolygonPath AsIs (SimplePolygon [Point2 0 0,Point2 10 10,Point2 100 200])]} :+ Attrs {NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr}),IpePath (Path {_pathSegments = fromList [PolygonPath AsIs (SimplePolygon [Point2 0 0,Point2 10 10,Point2 100 200])]} :+ Attrs {NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr})] :+ Attrs {Attr LayerName {_layerName = "alpha"}, NoAttr, NoAttr, NoAttr, NoAttr})
iO' :: HasDefaultIpeOut g => g -> IpeObject (NumType g) Source #
generate an ipe object without any specific attributes
Default Conversions
class ToObject (DefaultIpeOut g) => HasDefaultIpeOut g where Source #
Class that specifies a default conversion from a geometry type g into an ipe object.
Associated Types
type DefaultIpeOut g :: Type -> Type Source #
The type of ipe object (e.g. Path, Group, IpeSymbol) we render to
Methods
defIO :: IpeOut g (DefaultIpeOut g) (NumType g) Source #
The default way of rendering a value of type g into an ipe object. In particular, an ipe object of type 'DefaultIpeOut g'
Instances
Point Converters
Path Converters
defaultBox :: Num r => Rectangle (Point 2 r) Source #
Size of the default bounding box used to clip lines and half-lines in the default IpeOuts.
ipeLine :: (Ord r, Fractional r, Show r) => IpeOut (LinePV 2 r) Path r Source #
Renders a line as a Path. The line is clipped to the defaultBox
ipeLineIn :: (Ord r, Fractional r, Show r) => Rectangle (Point 2 r) -> IpeOut (LinePV 2 r) Path r Source #
Renders the line in the given box.
pre: the intersection of the box with the line is non-empty
ipeHalfLine :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => IpeOut (HalfLine point) Path r Source #
Renders an Halfine.
pre: the intersection of the box with the line is non-empty
ipeRay :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => IpeOut (HalfLine point) Path r Source #
Renders a ray, i.e. a half line drawing an arrow in the direction of the ray.
pre: the intersection of the box with the line is non-empty
ipeHalfLineIn :: (Ord r, Fractional r, Point_ point 2 r, Show r, Show point) => Rectangle point -> IpeOut (HalfLine point) Path r Source #
Renders the HalfLine in the given box.
pre: the intersection of the box with the halfline is a line segment
ipeLineSegment :: (LineSegment_ lineSegment point, Point_ point 2 r) => IpeOut lineSegment Path r Source #
Renders an line segment to a Path
path :: PathSegment r -> Path r Source #
Helper to construct a path from a singleton item
pathSegment :: (LineSegment_ lineSegment point, Point_ point 2 r) => lineSegment -> PathSegment r Source #
Construct a PolyLine path segment
toPolygonPathSegment :: (HasOuterBoundary polygon, Point_ point 2 r, Vertex polygon ~ point) => polygon -> PathSegment r Source #
Helper type to build a path segment
ipeSimplePolygon :: SimplePolygon_ simplePolygon point r => IpeOut simplePolygon Path r Source #
Draw a polygon
ipeSimplePolygon' :: forall (f :: Type -> Type) r. Foldable1 f => IpeOut (SimplePolygonF f (Point 2 r)) Path r Source #
Draw a polygon
review' :: Prism s t a b -> b -> t Source #
A slightly more general version of review that allows the s and t to differ. (and in some sense it is less general, since I don't care about monad constraints here)
ipeTriangle :: (Eq r, Num r) => IpeOut (Triangle (Point 2 r)) Path r Source #
Renders a polyline to a Path
ipeHalfPlane :: (Show r, Fractional r, Ord r) => IpeColor r -> IpeOut (HalfSpaceF (LinePV 2 r)) Group r Source #
Default rendering of halfplanes
ipeHalfPlaneIn :: (Ord r, Fractional r, Show r) => Rectangle (Point 2 r) -> IpeColor r -> IpeOut (HalfSpaceF (LinePV 2 r)) Group r Source #
Draw a halfplane in the given rectangle.
We draw both the border (in black) and the interior (20% transparant gray) of the halfpace
Group Converters
Text Converters
type InlineLaTeX = Text Source #
Type representing a single line of latex
Arguments
| :: (Show lbl, NumType g ~ r, ToObject i) | |
| => (g -> Point 2 r) | where to place the label |
| -> IpeOut g i r | how to draw the geometric object |
| -> IpeOut (g :+ lbl) Group r |
Annotate an IpeOut with a label
Arguments
| :: (Show lbl, NumType g ~ r, ToObject i) | |
| => IpeAttributes TextLabel r | attributes for the label |
| -> (g -> Point 2 r) | where to place the label |
| -> IpeOut g i r | how to draw the geometric object |
| -> IpeOut (g :+ lbl) Group r |
Annotate an IpeOut with a label
toInlineLatex :: Text -> InlineLaTeX Source #
Convert a text into a valid piece of inline latex