packages feed

Hieroglyph 1.2 → 1.21

raw patch · 3 files changed

+20/−26 lines, 3 files

Files

Graphics/Rendering/Hieroglyph/Cairo.hs view
@@ -79,15 +79,11 @@           RGB r g b = toSRGB c'            -fillStrokeAndClip state = do +fillStrokeAndClip state action = do      let (fr,fg,fb,fa) = colourToTuple . fillRGBA $ state         (sr,sg,sb,sa) = colourToTuple . strokeRGBA $ state-    when (filled state) $     -        Cairo.setSourceRGBA fr fg fb fa >> -        if (outlined state) then Cairo.fillPreserve else Cairo.fill-    when (outlined state) $ -        Cairo.setSourceRGBA sr sg sb sa >>-        Cairo.stroke+    when (filled state) $ Cairo.setSourceRGBA fr fg fb fa >> action >> Cairo.fill+    when (outlined state) $ Cairo.setSourceRGBA sr sg sb sa >> action >> Cairo.stroke     when (clipped state) $ Cairo.clip  renderCurveSegs (Line (Point x0 y0)) = Cairo.lineTo x0 y0@@ -98,18 +94,16 @@ renderPrimitive :: ImageCache -> Attributes -> Primitive -> Cairo.Render Attributes renderPrimitive _ s0 (Arc (Point cx cy) radius angle0 angle1 isnegative state) = do      applyAttributeDelta s0 state   -    if isnegative -        then Cairo.arcNegative cx cy radius angle0 angle1 -        else Cairo.arc cx cy radius angle0 angle1-    fillStrokeAndClip state+    fillStrokeAndClip state $ +        if isnegative then Cairo.arcNegative cx cy radius angle0 angle1 else Cairo.arc cx cy radius angle0 angle1     return state  renderPrimitive _ s0 (Path (Point ox oy) segs isclosed state) = do      applyAttributeDelta s0 state-    Cairo.moveTo ox oy-    forM_ segs $ renderCurveSegs-    when isclosed (Cairo.lineTo ox oy)-    fillStrokeAndClip state+    fillStrokeAndClip state $ do+        Cairo.moveTo ox oy+        forM_ segs $ renderCurveSegs+        when isclosed (Cairo.lineTo ox oy)      return state  renderPrimitive images s0 i@(Image filename (Left (Point ox oy)) _ state) = do@@ -137,21 +131,20 @@ renderPrimitive _ s0 (Hidden _) = return s0 renderPrimitive _ s0 (Rectangle (Point ox oy) w h state) = do      applyAttributeDelta s0 state-    Cairo.rectangle ox oy w h -    fillStrokeAndClip state+    fillStrokeAndClip state $ Cairo.rectangle ox oy w h      return state      renderPrimitive _ s0 (Text str (Point ox oy) state) = do     applyAttributeDelta s0 state -    Cairo.moveTo ox oy-    Cairo.showText str -    fillStrokeAndClip state+    fillStrokeAndClip state $ do +        Cairo.moveTo ox oy+        Cairo.showText str      return state      renderPrimitive images s0 (Union prims state) = do     let unfoc prim = prim{ attribs = (attribs prim){filled=False, outlined=False, clipped=False } }     applyAttributeDelta s0 state-    mapM_ (renderPrimitive images state . unfoc) prims >> fillStrokeAndClip state+    fillStrokeAndClip state $ forM_ prims (renderPrimitive images state . unfoc)      return state      render images d = loadStateIntoCairo attrs0
Graphics/Rendering/Hieroglyph/Visual.hs view
@@ -51,8 +51,8 @@ 	 -- | Declare that a Visual possibly occludes another Visual over :: (Visual t, Visual u) => t -> u -> BaseVisual-over this that = (map (\p -> p{ attribs = (attribs p){ layer = maxlev+1 }}) . primitives $ this) ++ primitives that-    where maxlev = maximum . map (layer . attribs) . primitives $ that +over this that = (map (\p -> p{ attribs = (attribs p){ layer = layer (attribs p) + maxlev + 1 }}) . primitives $ this) ++ primitives that+    where maxlev = if primitives that /= [] then maximum . map (layer . attribs) . primitives $ that else 0      infixr 9 `over` infixr 9 `moreSpecific`    @@ -60,7 +60,7 @@ -- | Declare that a Visual is more specific than another Visual. This way one drawing can have multiple levels of detail.     moreSpecific :: (Visual t, Visual u) => t -> u -> BaseVisual moreSpecific this that = (map (\p -> p{ attribs = (attribs p){ lod = maxlev+1 }}) . primitives $ this) ++ primitives that-    where maxlev = minimum . map (lod . attribs) . primitives $ that+    where maxlev = if primitives that /= [] then minimum . map (lod . attribs) . primitives $ that else 0      -- | Get an ordering of two Visuals to see if one possibly occludes the other.  The greater one is on top. isOverOrUnder :: (Visual t, Visual u) => t -> u -> Ordering
Hieroglyph.cabal view
@@ -1,10 +1,10 @@ Name:           Hieroglyph-Version:        1.2+Version:        1.21 Cabal-Version:  >= 1.2 License:        BSD3 License-File:   LICENSE Author:         J.R. Heard-Maintainer:     J.R. Heard+Maintainer:     J.R. Heard <jefferson.r.heard@gmail.com> Category:       Graphics Description:       A purely functional 2D scenegraph library with functionality similar to a barebones Processing.@@ -14,6 +14,7 @@  Library    Build-Depends: cairo, base, mtl, gtk, IfElse, containers, parallel, colour+   ghc-options: -O2 -fvia-C -optc-O2    Exposed-Modules:       Graphics.Rendering.Hieroglyph       Graphics.Rendering.Hieroglyph.Cairo