MyNixOS website logo
Description

Reading and Writing ipe7 files.

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

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.

Metadata

Version

0.13

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows