Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
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 r = g -> IpeObject' i r
- (!) :: IpeObject' i r -> IpeAttributes i r -> IpeObject' i r
- iO :: ToObject i => IpeObject' i r -> IpeObject r
- iO'' :: (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 :: * -> *
- defIO :: IpeOut g (DefaultIpeOut g) (NumType g)
- ipeMark :: Text -> IpeOut (Point 2 r) IpeSymbol r
- ipeDiskMark :: IpeOut (Point 2 r) IpeSymbol r
- ipeLineSegment :: IpeOut (LineSegment 2 p r) Path r
- ipePolyLine :: IpeOut (PolyLine 2 p r) Path r
- ipeDisk :: Floating r => IpeOut (Disk p r) Path r
- ipeCircle :: Floating r => IpeOut (Circle p r) Path r
- path :: PathSegment r -> Path r
- pathSegment :: LineSegment 2 p r -> PathSegment r
- ipePolygon :: IpeOut (Polygon t p r) Path r
- ipeGroup :: IpeOut [IpeObject r] Group r
Documentation
>>>
:set -XOverloadedStrings
>>>
:{
let myPolygon = fromPoints . map ext $ [origin, Point2 10 10, Point2 100 200] :}
The IpeOut type and the default combinator to use it
type IpeOut g i r = g -> IpeObject' i r Source #
(!) :: 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 = LSeq (fromList [PolygonPath SimplePolygon CSeq [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})
>>>
:{
iO $ ipeGroup [ iO $ ipePolygon myPolygon ! attr SFill (IpeColor "red") ] ! attr SLayer "alpha" :} IpeGroup (Group [IpePath (Path {_pathSegments = LSeq (fromList [PolygonPath SimplePolygon CSeq [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})] :+ Attrs {Attr LayerName {_layerName = "alpha"}, NoAttr, NoAttr, NoAttr, NoAttr})
iO'' :: (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 = LSeq (fromList [PolygonPath SimplePolygon CSeq [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})
>>>
iO'' [ myPolygon , myPolygon ] $ attr SLayer "alpha"
IpeGroup (Group [IpePath (Path {_pathSegments = LSeq (fromList [PolygonPath SimplePolygon CSeq [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}),IpePath (Path {_pathSegments = LSeq (fromList [PolygonPath SimplePolygon CSeq [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})] :+ 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.
type DefaultIpeOut g :: * -> * Source #
Instances
Point Converters
Path Converters
ipeLineSegment :: IpeOut (LineSegment 2 p r) Path r Source #
path :: PathSegment r -> Path r Source #
Helper to construct a path from a singleton item
pathSegment :: LineSegment 2 p r -> PathSegment r Source #