wumpus-microprint 0.1.1 → 0.2.0
raw patch · 5 files changed
+54/−33 lines, 5 filesdep ~wumpus-basicdep ~wumpus-corePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: wumpus-basic, wumpus-core
API changes (from Hackage documentation)
- Wumpus.MicroPrint.Render: type DGraphic = Graphic Double
- Wumpus.MicroPrint.Render: type Graphic u = H (Primitive u)
+ Wumpus.MicroPrint.Render: borderedF :: Double -> DrawF
+ Wumpus.MicroPrint.Render: type DrawF = (Int, Double) -> (Double, Double) -> DRGB -> DGraphicF
- Wumpus.MicroPrint.Render: MP_config :: Double -> Double -> Double -> (Double -> Double -> DRGB -> DGraphicF) -> MP_config
+ Wumpus.MicroPrint.Render: MP_config :: Double -> Double -> Double -> DrawF -> MP_config
- Wumpus.MicroPrint.Render: drawF :: MP_config -> Double -> Double -> DRGB -> DGraphicF
+ Wumpus.MicroPrint.Render: drawF :: MP_config -> DrawF
- Wumpus.MicroPrint.Render: greekF :: Double -> Double -> DRGB -> DGraphicF
+ Wumpus.MicroPrint.Render: greekF :: DrawF
Files
- CHANGES +8/−0
- demo/Demo01.hs +2/−2
- src/Wumpus/MicroPrint/Render.hs +32/−27
- src/Wumpus/MicroPrint/VersionNumber.hs +1/−1
- wumpus-microprint.cabal +11/−3
CHANGES view
@@ -1,4 +1,12 @@ +0.1.1 to 0.2.0:++ * Updated to use Basic.Graphic types from wumpus-basic-0.2.0.++ * Added bordered printing that marks the unit character width.++ + 0.1.0 to 0.1.1: * Added missing LICENSE file to the Cabal file.
demo/Demo01.hs view
@@ -21,7 +21,7 @@ ; writeSVG_latin1 "./out/mp01.svg" pic1 } where- prefix mp = setRGB lightSlateGrey >> mp+ prefix mp = setRGB moccasin >> mp errK :: a errK = error "no picture"@@ -43,7 +43,7 @@ { char_height = 12.0 , char_width = 8.0 , line_spacing = 3.0- , drawF = greekF+ , drawF = borderedF 1.0 }
src/Wumpus/MicroPrint/Render.hs view
@@ -18,53 +18,66 @@ module Wumpus.MicroPrint.Render (- - Graphic- , DGraphic++ DrawF , MP_config(..) , greekF+ , borderedF , drawMicroPrint ) where import Wumpus.Core+import Wumpus.Core.Colour ( black )+import Wumpus.Basic.Graphic import Wumpus.Basic.Monads.TraceMonad import Wumpus.Basic.Monads.TurtleMonad import Wumpus.Basic.Utils.HList import Wumpus.MicroPrint.DrawMonad ( Tile(..), Height ) -import Data.AffineSpace -- package: vector-space import MonadLib -- package: monadLib+import Data.AffineSpace -- package: vector-space import Control.Applicative import Control.Monad --- | Note - this representation allows for zero, one or more--- Primitives to be collected together.+-- | 'DrawF' :+-- @ (num_chars, char_unit_width) * (full_width, full_height) -> rgb -> DGraphicF @ ---type Graphic u = H (Primitive u)--type DGraphic = Graphic Double--type GraphicF u = Point2 u -> Graphic u--type DGraphicF = GraphicF Double -+type DrawF = (Int,Double) -> (Double,Double) -> DRGB -> DGraphicF data MP_config = MP_config { char_height :: Double , char_width :: Double , line_spacing :: Double - , drawF :: Double -> Double -> DRGB -> DGraphicF+ , drawF :: DrawF } -greekF :: Double -> Double -> DRGB -> DGraphicF-greekF w h rgb = filledRectangle rgb w h +greekF :: DrawF+greekF _ (w,h) rgb = filledRectangle rgb w h +borderedF :: Double -> DrawF+borderedF line_width (i,uw) (w,h) rgb = + srect `cc` seps `cc` greekF (i,uw) (w,h) rgb+ where+ props = (black, LineWidth line_width) + srect :: DGraphicF+ srect = strokedRectangle props w h+ + seps :: DGraphicF+ seps = \pt -> unfoldrH (phi pt) (1,uw) + + phi pt (n,disp) | n >= i = Nothing+ | otherwise = let ln = vline props h (pt .+^ hvec disp)+ in Just (ln,(n+1,disp+uw))+ +vline :: (Stroke t, Num u, Ord u) => t -> u -> Point2 u -> Primitive u+vline t h = \pt -> ostroke t $ path pt [lineTo $ pt .+^ vvec h]+ newtype RenderMonad a = RM { getRM :: ReaderT MP_config ( TraceT DPrimitive Turtle) a }@@ -114,9 +127,10 @@ interp1 (Word rgb i) = do w <- scaleWidth i h <- asks char_height+ uw <- asks char_width pt <- scaleCurrentCoord dF <- asks drawF- trace (dF w h rgb pt)+ trace (dF (i,uw) (w,h) rgb pt) moveRightN i moveRightN :: Int -> RenderMonad ()@@ -137,13 +151,4 @@ -------------------------------------------------------------------------------- -filledRectangle :: (Num u, Ord u, Fill t) - => t -> u -> u -> GraphicF u-filledRectangle t w h bl = wrapH $ fill t $ rectangle w h bl -rectangle :: Num u => u -> u -> Point2 u -> Path u-rectangle w h bl = path bl [ lineTo br, lineTo tr, lineTo tl ]- where- br = bl .+^ hvec w- tr = br .+^ vvec h- tl = bl .+^ vvec h
src/Wumpus/MicroPrint/VersionNumber.hs view
@@ -22,4 +22,4 @@ wumpus_microprint_version :: (Int,Int,Int)-wumpus_microprint_version = (0,1,1)+wumpus_microprint_version = (0,2,0)
wumpus-microprint.cabal view
@@ -1,5 +1,5 @@ name: wumpus-microprint-version: 0.1.1+version: 0.2.0 license: BSD3 license-file: LICENSE copyright: Stephen Tetley <stephen.tetley@gmail.com>@@ -19,7 +19,15 @@ . \[1\] <http://scg.unibe.ch/archive/papers/Robb05b-microprintsESUG.pdf> .+ Changelog: .+ 0.1.1 to 0.2.0:+ .+ * Updated to use Basic.Graphic types from wumpus-basic-0.2.0+ .+ * Added bordered printing that marks the unit character width.+ .+ . build-type: Simple stability: highly unstable cabal-version: >= 1.2@@ -34,8 +42,8 @@ build-depends: base < 5, vector-space >= 0.6, monadLib >= 3.6,- wumpus-core >= 0.20.0,- wumpus-basic >= 0.1.0+ wumpus-core >= 0.21.0,+ wumpus-basic >= 0.2.0 exposed-modules: