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

Ipe.FromIpe

Description

Functions that help reading geometric values from ipe images.

Synopsis

Individual readers

_asPoint :: forall r p f. (Choice p, Applicative f) => p (Point 2 r) (f (Point 2 r)) -> p (IpeSymbol r) (f (IpeSymbol r)) Source #

Extracts the point from a Symbol. When creating a symbol this creates a disk that supports a stroke color.

_asLineSegment :: forall r p f. (Choice p, Applicative f) => p (LineSegment AnEndPoint (Point 2 r)) (f (LineSegment AnEndPoint (Point 2 r))) -> p (Path r) (f (Path 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.

_asClosedLineSegment :: forall r p f. (Choice p, Applicative f) => p (ClosedLineSegment (Point 2 r)) (f (ClosedLineSegment (Point 2 r))) -> p (Path r) (f (Path 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.

_asRectangle :: (Num r, Ord r) => Prism' (Path r) (Rectangle (Point 2 r)) Source #

Tries to convert a path into a rectangle.

_asTriangle :: forall r p f. (Choice p, Applicative f) => p (Triangle (Point 2 r)) (f (Triangle (Point 2 r))) -> p (Path r) (f (Path r)) Source #

Convert to a triangle

_asPolyLine :: forall r p f. (Choice p, Applicative f) => p (PolyLine (Point 2 r)) (f (PolyLine (Point 2 r))) -> p (Path r) (f (Path r)) Source #

Convert to a polyline. Ignores all non-polyline parts

>>> testPath ^? _asPolyLine
Just (PolyLine [Point2 0 0,Point2 10 10,Point2 200 100])

_asSimplePolygon :: forall (f :: Type -> Type) r. Foldable1 f => Prism (Path r) (Path r) (SimplePolygon (Point 2 r)) (SimplePolygonF f (Point 2 r)) Source #

Convert to a simple polygon

_asConvexPolygon :: (Num r, Ord r) => Prism' (Path r) (ConvexPolygon (Point 2 r)) Source #

Convert to a convex polygon

_asPolygonalDomain :: forall r p f. (Choice p, Applicative f) => p (PolygonalDomain (Point 2 r)) (f (PolygonalDomain (Point 2 r))) -> p (Path r) (f (Path r)) Source #

Convert to a polygonal domain

toPolygonalDomain :: Path r -> Maybe (PolygonalDomainF Seq (Cyclic NonEmptyVector) (Point 2 r)) Source #

Convert to a path to a Polygonal Domain

Dealing with Attributes

_withAttrs :: forall r (i :: Type -> Type) g. 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 [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, NoAttr})

Default readers

class HasDefaultFromIpe g where Source #

Associated Types

type DefaultFromIpe g :: Type -> Type Source #

Instances

Instances details
(Radical r, Eq r) => HasDefaultFromIpe (Circle (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

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

Defined in Ipe.FromIpe

(Radical r, Eq r) => HasDefaultFromIpe (Disk (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

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

Defined in Ipe.FromIpe

type DefaultFromIpe (Disk (Point 2 r)) = Path
(Num r, Ord r) => HasDefaultFromIpe (Rectangle (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

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

Defined in Ipe.FromIpe

HasDefaultFromIpe (Ellipse r) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (Ellipse r) 
Instance details

Defined in Ipe.FromIpe

(Fractional r, Ord r, Show r) => HasDefaultFromIpe (HalfLine (Point 2 r)) Source # 
Instance details

Defined in Ipe

Associated Types

type DefaultFromIpe (HalfLine (Point 2 r)) 
Instance details

Defined in Ipe

HasDefaultFromIpe (ClosedLineSegment (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (ClosedLineSegment (Point 2 r)) 
Instance details

Defined in Ipe.FromIpe

HasDefaultFromIpe (Triangle (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

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

Defined in Ipe.FromIpe

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

Defined in Ipe.FromIpe

Associated Types

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

Defined in Ipe.FromIpe

(Num r, Ord r) => HasDefaultFromIpe (ConvexPolygon (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (ConvexPolygon (Point 2 r)) 
Instance details

Defined in Ipe.FromIpe

HasDefaultFromIpe (SimplePolygon (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (SimplePolygon (Point 2 r)) 
Instance details

Defined in Ipe.FromIpe

HasDefaultFromIpe (LineSegment AnEndPoint (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (LineSegment AnEndPoint (Point 2 r)) 
Instance details

Defined in Ipe.FromIpe

HasDefaultFromIpe (Point 2 r) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (Point 2 r) 
Instance details

Defined in Ipe.FromIpe

(Num r, Ord r) => HasDefaultFromIpe (UnboundedConvexRegionF r NonEmpty (Point 2 r)) Source # 
Instance details

Defined in Ipe.FromIpe

Associated Types

type DefaultFromIpe (UnboundedConvexRegionF r NonEmpty (Point 2 r)) 
Instance details

Defined in Ipe.FromIpe

Reading all elements of a particular type

readAll :: (HasDefaultFromIpe g, r ~ NumType g) => IpePage r -> [g :+ IpeAttributes (DefaultFromIpe g) r] Source #

Read all g's from some ipe page(s).

readAllDeep :: (HasDefaultFromIpe g, r ~ NumType g) => IpePage r -> [g :+ IpeAttributes (DefaultFromIpe g) r] Source #

Read all as looking into groups

readAllFrom :: (HasDefaultFromIpe g, r ~ NumType g, Coordinate r, Eq r) => OsPath -> 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".