hgeometry-ipe: Reading and Writing ipe7 files.

[ bsd3, geometry, library ] [ Propose Tags ]

Reading and Writing ipe7 files and converting them to and from HGeometry types.


[Skip to Readme]
Versions [RSS] [faq] 0.9.0.0, 0.10.0.0, 0.11.0.0, 0.12.0.0, 0.13
Change log changelog
Dependencies aeson (>=1.0), base (>=4.11 && <5), bifunctors (>=4.1), bytestring (>=0.10), colour (>=2.3.3), containers (>=0.5.5), data-clist (>=0.0.7.2), deepseq (>=1.1), directory (>=1.3), dlist (>=0.7), filepath (>=1.4), fingertree (>=0.1), fixed-vector (>=1.0), hexpat (>=0.20.9), hgeometry (>=0.13), hgeometry-combinatorial (>=0.13), lens (>=4.2), linear (>=1.10), MonadRandom (>=0.5), mtl, parsec (>=3), QuickCheck (>=2.5), quickcheck-instances (>=0.3), random, reflection (>=2.1), semigroupoids (>=5), semigroups (>=0.18), singletons (>=2 && <4), singletons-th (==3.*), template-haskell, text (>=1.1.1.0), typed-process (>=0.2.6), vector (>=0.11), vinyl (>=0.10), yaml (>=0.8) [details]
License BSD-3-Clause
Author Frank Staals
Maintainer frank@fstaals.net
Category Geometry
Home page https://fstaals.net/software/hgeometry
Source repo head: git clone https://github.com/noinia/hgeometry
Uploaded by FrankStaals at 2021-11-13T10:34:46Z
Distributions NixOS:0.12.0.0
Downloads 2429 total (31 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-11-13 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for hgeometry-ipe-0.13

[back to package description]

HGeometry-ipe

This package provides an API for reading and writing Ipe (http://ipe.otfried.org) files. This is all very work in progress. Hence, the API is experimental and may change at any time!

Here is an example showing reading a set of points from an Ipe file, computing the DelaunayTriangulation and the Euclidean Minimimum Spanning tree, and writing the result again to an output file. Refer to hgeometry-examples for the full code.

mainWith                          :: Options -> IO ()
mainWith (Options inFile outFile) = do
  pts <- readAllFrom @(Point 2 R) inFile
  let pts' = NonEmpty.fromList pts
      dt   = toPlanarSubdivision (Proxy @DTWorld) . delaunayTriangulation $ pts'
      emst = euclideanMST pts'
      out  = [ iO $ drawPlanarSubdivisionWith drawVtx drawEdge (drawInternalFace dt) drawOuterFace dt
                  ! attr SLayer "delaunayTriangulation"
             , iO $ drawTree' emst ! attr SLayer "emst"
             ]
      outputFile = singlePageFromContent out
  outputFile' <- addStyleSheetFrom "../hgeometry-ipe/resources/opacities.isy" outputFile
  writeIpeFile outFile outputFile'

-- | The world in which the delaunay triangulation "lives"
data DTWorld

-- | Draw vertices using their default representation; disk marks. For
-- the rest we keep their original attributes.
drawVtx                         :: IpeOut' Maybe (VertexId' s, VertexData r (IpeAttributes IpeSymbol r)) IpeSymbol r
drawVtx (_vi, VertexData p ats) = Just $ defIO p ! ats

-- | Draw edges using normal line segments
drawEdge              :: IpeOut' Maybe (Dart s,      LineSegment 2 v r :+ e)  Path r
drawEdge (_d, s :+ _) = Just $ defIO s

-- | Internal faces are filled polygons.
drawInternalFace                 :: PlanarSubdivision s v e f r
                                 -> IpeOut' Maybe (FaceId' s,   SomePolygon v r :+ f)    Path r
drawInternalFace s (fi, pg :+ _) = Just $ defIO pg ! attr SFill lightcyan

--
drawOuterFace :: (Ord r, Num r) => IpeOut' Maybe (FaceId' s,   MultiPolygon (Maybe v) r :+ f) Path r
drawOuterFace (_, pg :+ _) = Just $ defIO pg ! attr SOpacity "10%"
                                             ! attr SFill lightgray

See the hgeometry-examples package for more examples.