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

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

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

Instances details
HasDefaultIpeOut a => HasDefaultIpeOut (NonEmpty a) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (NonEmpty a) 
Instance details

Defined in Ipe.IpeOut

HasDefaultIpeOut (Group r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Group r) 
Instance details

Defined in Ipe.IpeOut

Radical r => HasDefaultIpeOut (Circle (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Circle (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (Circle (Point 2 r)) (DefaultIpeOut (Circle (Point 2 r))) (NumType (Circle (Point 2 r))) Source #

Radical r => HasDefaultIpeOut (Disk (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Disk (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut (Disk (Point 2 r)) = Path

Methods

defIO :: IpeOut (Disk (Point 2 r)) (DefaultIpeOut (Disk (Point 2 r))) (NumType (Disk (Point 2 r))) Source #

(Radical r, Fractional r, Point_ point 2 r) => HasDefaultIpeOut (DiametralBall point) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (DiametralBall point) 
Instance details

Defined in Ipe.IpeOut

Num r => HasDefaultIpeOut (Rectangle (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Rectangle (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

(Radical r, Fractional r, Point_ point 2 r) => HasDefaultIpeOut (DiskByPoints point) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (DiskByPoints point) 
Instance details

Defined in Ipe.IpeOut

HasDefaultIpeOut (Ellipse r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Ellipse r) 
Instance details

Defined in Ipe.IpeOut

(Fractional r, Ord r, Point_ point 2 r, Show r, Show point) => HasDefaultIpeOut (HalfLine point) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (HalfLine point) 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut (HalfLine point) = Path

Methods

defIO :: IpeOut (HalfLine point) (DefaultIpeOut (HalfLine point)) (NumType (HalfLine point)) Source #

(Fractional r, Ord r, Show r) => HasDefaultIpeOut (HalfSpaceF (LineEQ r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (HalfSpaceF (LineEQ r)) 
Instance details

Defined in Ipe.IpeOut

(Fractional r, Ord r, Show r) => HasDefaultIpeOut (HalfSpaceF (LinePV 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (HalfSpaceF (LinePV 2 r)) 
Instance details

Defined in Ipe.IpeOut

(Fractional r, Ord r, Show r) => HasDefaultIpeOut (VerticalOrLineEQ r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (VerticalOrLineEQ r) 
Instance details

Defined in Ipe.IpeOut

(Fractional r, Ord r, Show r) => HasDefaultIpeOut (LineEQ r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (LineEQ r) 
Instance details

Defined in Ipe.IpeOut

(Eq r, Num r) => HasDefaultIpeOut (Triangle (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Triangle (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

HasDefaultIpeOut (PolyLine (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (PolyLine (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

HasDefaultIpeOut a => HasDefaultIpeOut [a] Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut [a] 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut [a] = Group

Methods

defIO :: IpeOut [a] (DefaultIpeOut [a]) (NumType [a]) Source #

(HasDefaultIpeOut a, HasDefaultIpeOut b, DefaultIpeOut a ~ DefaultIpeOut b, NumType a ~ NumType b) => HasDefaultIpeOut (Either a b) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Either a b) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (Either a b) (DefaultIpeOut (Either a b)) (NumType (Either a b)) Source #

(HasDefaultIpeOut g, a ~ IpeAttributes (DefaultIpeOut g) (NumType g)) => HasDefaultIpeOut (g :+ a) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (g :+ a) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (g :+ a) (DefaultIpeOut (g :+ a)) (NumType (g :+ a)) Source #

(Radical r, Fractional r, Point_ point 2 r) => HasDefaultIpeOut (BallByPoints' 3 point) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (BallByPoints' 3 point) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (BallByPoints' 3 point) (DefaultIpeOut (BallByPoints' 3 point)) (NumType (BallByPoints' 3 point)) Source #

(Fractional r, Ord r, Show r) => HasDefaultIpeOut (LinePV 2 r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (LinePV 2 r) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (LinePV 2 r) (DefaultIpeOut (LinePV 2 r)) (NumType (LinePV 2 r)) Source #

(IxValue (endPoint (Point 2 r)) ~ Point 2 r, EndPoint_ (endPoint (Point 2 r))) => HasDefaultIpeOut (LineSegment endPoint (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (LineSegment endPoint (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut (LineSegment endPoint (Point 2 r)) = Path

Methods

defIO :: IpeOut (LineSegment endPoint (Point 2 r)) (DefaultIpeOut (LineSegment endPoint (Point 2 r))) (NumType (LineSegment endPoint (Point 2 r))) Source #

HasDefaultIpeOut (Point 2 r) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (Point 2 r) 
Instance details

Defined in Ipe.IpeOut

Methods

defIO :: IpeOut (Point 2 r) (DefaultIpeOut (Point 2 r)) (NumType (Point 2 r)) Source #

(HasDefaultIpeOut original, HasDefaultIpeOut extra, DefaultIpeOut original ~ DefaultIpeOut extra, NumType original ~ NumType extra) => HasDefaultIpeOut (OriginalOrExtra original extra) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (OriginalOrExtra original extra) 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut (OriginalOrExtra original extra) = DefaultIpeOut original

Methods

defIO :: IpeOut (OriginalOrExtra original extra) (DefaultIpeOut (OriginalOrExtra original extra)) (NumType (OriginalOrExtra original extra)) Source #

(HasDefaultIpeOut vertex, HasDefaultIpeOut polygon, NumType vertex ~ NumType polygon, Point_ vertex 2 r) => HasDefaultIpeOut (PossiblyDegenerateSimplePolygon vertex polygon) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (PossiblyDegenerateSimplePolygon vertex polygon) 
Instance details

Defined in Ipe.IpeOut

(VertexContainer f (Point 2 r), HasFromFoldable1 f) => HasDefaultIpeOut (ConvexPolygonF f (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (ConvexPolygonF f (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

(Num r, Point_ vertex 2 r, Foldable1 nonEmpty) => HasDefaultIpeOut (UnboundedConvexRegionF r nonEmpty vertex) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (UnboundedConvexRegionF r nonEmpty vertex) 
Instance details

Defined in Ipe.IpeOut

type DefaultIpeOut (UnboundedConvexRegionF r nonEmpty vertex) = Path

Methods

defIO :: IpeOut (UnboundedConvexRegionF r nonEmpty vertex) (DefaultIpeOut (UnboundedConvexRegionF r nonEmpty vertex)) (NumType (UnboundedConvexRegionF r nonEmpty vertex)) Source #

(VertexContainer f (Point 2 r), HasFromFoldable1 f) => HasDefaultIpeOut (SimplePolygonF f (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (SimplePolygonF f (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

(HoleContainer h f (Point 2 r), HasFromFoldable1 f) => HasDefaultIpeOut (PolygonalDomainF h f (Point 2 r)) Source # 
Instance details

Defined in Ipe.IpeOut

Associated Types

type DefaultIpeOut (PolygonalDomainF h f (Point 2 r)) 
Instance details

Defined in Ipe.IpeOut

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

ipePolyLine :: IpeOut (PolyLine (Point 2 r)) Path r Source #

Renders a polyline to a Path

ipeEllipse :: IpeOut (Ellipse r) Path r Source #

Renders an Ellipse to a Path

ipeCircle :: Radical r => IpeOut (Circle (Point 2 r)) Path r Source #

Renders a circle to a Path

ipeDisk :: Radical r => IpeOut (Disk (Point 2 r)) Path r Source #

Renders a Disk to a Path

ipeBezier :: IpeOut (CubicBezier (Point 2 r)) Path r Source #

Renders a Bezier curve 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

ipePolygon :: Polygon_ polygon point r => IpeOut polygon Path r Source #

Render as a polygon

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)

ipeRectangle :: Num r => IpeOut (Rectangle (Point 2 r)) Path r Source #

Draw a Rectangle

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

ipeLabel :: IpeOut (InlineLaTeX :+ Point 2 r) TextLabel r Source #

Creates an text label

labelled Source #

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

labelledWith Source #

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