Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Functions that help reading geometric values from ipe images.
Synopsis
- _asLineSegment :: Prism' (Path r) (LineSegment 2 () r)
- _asPolyLine :: Prism' (Path r) (PolyLine 2 () r)
- _asSimplePolygon :: Prism' (Path r) (Polygon Simple () r)
- _asTriangle :: Prism' (Path r) (Triangle 2 () r)
- _asMultiPolygon :: Prism' (Path r) (MultiPolygon () r)
- _asSomePolygon :: Prism' (Path r) (SomePolygon () r)
- polygonToPath :: Polygon t () r -> Path r
- pathToPolygon :: Path r -> Maybe (Either (SimplePolygon () r) (MultiPolygon () r))
- _withAttrs :: Prism' (IpeObject r) (i r :+ IpeAttributes i r) -> Prism' (i r) g -> Prism' (IpeObject r) (g :+ IpeAttributes i r)
- class HasDefaultFromIpe g where
- type DefaultFromIpe g :: * -> *
- defaultFromIpe :: r ~ NumType g => Prism' (IpeObject r) (g :+ IpeAttributes (DefaultFromIpe g) r)
- readAll :: (HasDefaultFromIpe g, r ~ NumType g, Foldable f) => f (IpePage r) -> [g :+ IpeAttributes (DefaultFromIpe g) r]
- readAllFrom :: (HasDefaultFromIpe g, r ~ NumType g, Coordinate r, Eq r) => FilePath -> IO [g :+ IpeAttributes (DefaultFromIpe g) r]
- fromSingleton :: a -> LSeq 1 a
Documentation
>>>
:set -XOverloadedStrings
>>>
import Data.Geometry.Ipe.Attributes
>>>
import Data.Geometry.Ipe.Color(IpeColor(..))
>>>
import Data.Geometry.Point
>>>
:{
let testPath :: Path Int testPath = Path . fromSingleton . PolyLineSegment . PolyLine.fromPoints . map ext $ [ origin, point2 10 10, point2 200 100 ] testPathAttrs :: IpeAttributes Path Int testPathAttrs = attr SStroke (IpeColor "red") testObject :: IpeObject Int testObject = IpePath (testPath :+ testPathAttrs) :}
_asLineSegment :: Prism' (Path r) (LineSegment 2 () r) Source #
Try to convert a path into a line segment, fails if the path is not a line segment or a polyline with more than two points.
_asPolyLine :: Prism' (Path r) (PolyLine 2 () r) Source #
Convert to a polyline. Ignores all non-polyline parts
>>>
testPath ^? _asPolyLine
Just (PolyLine {_points = LSeq (fromList [Point2 [0,0] :+ (),Point2 [10,10] :+ (),Point2 [200,100] :+ ()])})
_asSimplePolygon :: Prism' (Path r) (Polygon Simple () r) Source #
Convert to a simple polygon
_asTriangle :: Prism' (Path r) (Triangle 2 () r) Source #
Convert to a triangle
_asMultiPolygon :: Prism' (Path r) (MultiPolygon () r) Source #
Convert to a multipolygon
_asSomePolygon :: Prism' (Path r) (SomePolygon () r) Source #
polygonToPath :: Polygon t () r -> Path r Source #
_withAttrs :: Prism' (IpeObject r) (i r :+ IpeAttributes i r) -> Prism' (i r) g -> Prism' (IpeObject r) (g :+ IpeAttributes i r) Source #
Use the first prism to select the ipe object to depicle with, and the second how to select the geometry object from there on. Then we can select the geometry object, directly with its attributes here.
>>>
testObject ^? _withAttrs _IpePath _asPolyLine
Just (PolyLine {_points = LSeq (fromList [Point2 [0,0] :+ (),Point2 [10,10] :+ (),Point2 [200,100] :+ ()])} :+ Attrs {NoAttr, NoAttr, NoAttr, NoAttr, Attr IpeColor (Named "red"), NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr, NoAttr})
class HasDefaultFromIpe g where Source #
type DefaultFromIpe g :: * -> * Source #
defaultFromIpe :: r ~ NumType g => Prism' (IpeObject r) (g :+ IpeAttributes (DefaultFromIpe g) r) Source #
Instances
HasDefaultFromIpe (MultiPolygon () r) Source # | |
Defined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (MultiPolygon () r) :: Type -> Type Source # defaultFromIpe :: r0 ~ NumType (MultiPolygon () r) => Prism' (IpeObject r0) (MultiPolygon () r :+ IpeAttributes (DefaultFromIpe (MultiPolygon () r)) r0) Source # | |
HasDefaultFromIpe (SimplePolygon () r) Source # | |
Defined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (SimplePolygon () r) :: Type -> Type Source # defaultFromIpe :: r0 ~ NumType (SimplePolygon () r) => Prism' (IpeObject r0) (SimplePolygon () r :+ IpeAttributes (DefaultFromIpe (SimplePolygon () r)) r0) Source # | |
HasDefaultFromIpe (LineSegment 2 () r) Source # | |
Defined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (LineSegment 2 () r) :: Type -> Type Source # defaultFromIpe :: r0 ~ NumType (LineSegment 2 () r) => Prism' (IpeObject r0) (LineSegment 2 () r :+ IpeAttributes (DefaultFromIpe (LineSegment 2 () r)) r0) Source # | |
HasDefaultFromIpe (PolyLine 2 () r) Source # | |
Defined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (PolyLine 2 () r) :: Type -> Type Source # defaultFromIpe :: r0 ~ NumType (PolyLine 2 () r) => Prism' (IpeObject r0) (PolyLine 2 () r :+ IpeAttributes (DefaultFromIpe (PolyLine 2 () r)) r0) Source # |
readAll :: (HasDefaultFromIpe g, r ~ NumType g, Foldable f) => f (IpePage r) -> [g :+ IpeAttributes (DefaultFromIpe g) r] Source #
Read all g's from some ipe page(s).
readAllFrom :: (HasDefaultFromIpe g, r ~ NumType g, Coordinate r, Eq r) => FilePath -> IO [g :+ IpeAttributes (DefaultFromIpe g) r] Source #
Convenience function from reading all g's from an ipe file. If there is an error reading or parsing the file the error is "thrown away".
fromSingleton :: a -> LSeq 1 a Source #