wumpus-core 0.22.0 → 0.23.0
raw patch · 16 files changed
+214/−116 lines, 16 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Wumpus.Core.FontSize: charWidth :: FontSize -> PtSize
+ Wumpus.Core.Geometry: vlength :: (Floating u) => Vec2 u -> u
+ Wumpus.Core.GraphicsState: FontFace :: String -> String -> SVGFontStyle -> FontFace
+ Wumpus.Core.GraphicsState: data FontFace
+ Wumpus.Core.GraphicsState: font_face :: FontAttr -> FontFace
+ Wumpus.Core.GraphicsState: instance Eq FontFace
+ Wumpus.Core.GraphicsState: instance Ord FontAttr
+ Wumpus.Core.GraphicsState: instance Ord FontFace
+ Wumpus.Core.GraphicsState: instance Ord SVGFontStyle
+ Wumpus.Core.GraphicsState: instance Show FontFace
+ Wumpus.Core.PtSize: class FromPtSize u
+ Wumpus.Core.PtSize: data PtSize
+ Wumpus.Core.PtSize: fromPtSize :: (FromPtSize u) => PtSize -> u
+ Wumpus.Core.PtSize: instance Eq PtSize
+ Wumpus.Core.PtSize: instance Floating PtSize
+ Wumpus.Core.PtSize: instance Fractional PtSize
+ Wumpus.Core.PtSize: instance FromPtSize Double
+ Wumpus.Core.PtSize: instance Num PtSize
+ Wumpus.Core.PtSize: instance Ord PtSize
+ Wumpus.Core.PtSize: instance Show PtSize
+ Wumpus.Core.PtSize: ptSize :: PtSize -> Double
- Wumpus.Core.FontSize: courier48_ascender_height :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_ascender_height :: PtSize
- Wumpus.Core.FontSize: courier48_descender_depth :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_descender_depth :: PtSize
- Wumpus.Core.FontSize: courier48_height :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_height :: PtSize
- Wumpus.Core.FontSize: courier48_numeral_height :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_numeral_height :: PtSize
- Wumpus.Core.FontSize: courier48_spacer_width :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_spacer_width :: PtSize
- Wumpus.Core.FontSize: courier48_width :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_width :: PtSize
- Wumpus.Core.FontSize: courier48_xheight :: (Num u) => u
+ Wumpus.Core.FontSize: courier48_xheight :: PtSize
- Wumpus.Core.FontSize: descenderDepth :: (Fractional u) => FontSize -> u
+ Wumpus.Core.FontSize: descenderDepth :: FontSize -> PtSize
- Wumpus.Core.FontSize: numeralHeight :: (Fractional u) => FontSize -> u
+ Wumpus.Core.FontSize: numeralHeight :: FontSize -> PtSize
- Wumpus.Core.FontSize: textBounds :: (Fractional u, Ord u) => FontSize -> Point2 u -> CharCount -> BoundingBox u
+ Wumpus.Core.FontSize: textBounds :: (Fractional u, Ord u, FromPtSize u) => FontSize -> Point2 u -> CharCount -> BoundingBox u
- Wumpus.Core.FontSize: textHeight :: (Num u) => FontSize -> u
+ Wumpus.Core.FontSize: textHeight :: FontSize -> PtSize
- Wumpus.Core.FontSize: textWidth :: (Fractional u) => FontSize -> CharCount -> u
+ Wumpus.Core.FontSize: textWidth :: FontSize -> CharCount -> PtSize
- Wumpus.Core.FontSize: widthAt48pt :: (Fractional u) => CharCount -> u
+ Wumpus.Core.FontSize: widthAt48pt :: CharCount -> PtSize
- Wumpus.Core.FontSize: xcharHeight :: (Fractional u) => FontSize -> u
+ Wumpus.Core.FontSize: xcharHeight :: FontSize -> PtSize
- Wumpus.Core.GraphicsState: FontAttr :: String -> String -> SVGFontStyle -> Int -> FontAttr
+ Wumpus.Core.GraphicsState: FontAttr :: Int -> FontFace -> FontAttr
- Wumpus.Core.GraphicsState: font_name :: FontAttr -> String
+ Wumpus.Core.GraphicsState: font_name :: FontFace -> String
- Wumpus.Core.GraphicsState: svg_font_family :: FontAttr -> String
+ Wumpus.Core.GraphicsState: svg_font_family :: FontFace -> String
- Wumpus.Core.GraphicsState: svg_font_style :: FontAttr -> SVGFontStyle
+ Wumpus.Core.GraphicsState: svg_font_style :: FontFace -> SVGFontStyle
- Wumpus.Core.Picture: frame :: (Real u, Floating u) => Primitive u -> Picture u
+ Wumpus.Core.Picture: frame :: (Real u, Floating u, FromPtSize u) => Primitive u -> Picture u
- Wumpus.Core.Picture: frameMulti :: (Real u, Floating u) => [Primitive u] -> Picture u
+ Wumpus.Core.Picture: frameMulti :: (Real u, Floating u, FromPtSize u) => [Primitive u] -> Picture u
- Wumpus.Core.Picture: frameWithin :: (Real u, Floating u) => Primitive u -> BoundingBox u -> Picture u
+ Wumpus.Core.Picture: frameWithin :: (Real u, Floating u, FromPtSize u) => Primitive u -> BoundingBox u -> Picture u
- Wumpus.Core.Picture: illustrateBounds :: (Real u, Floating u) => DRGB -> Picture u -> Picture u
+ Wumpus.Core.Picture: illustrateBounds :: (Real u, Floating u, FromPtSize u) => DRGB -> Picture u -> Picture u
- Wumpus.Core.Picture: illustrateBoundsPrim :: (Real u, Floating u) => DRGB -> Primitive u -> Picture u
+ Wumpus.Core.Picture: illustrateBoundsPrim :: (Real u, Floating u, FromPtSize u) => DRGB -> Primitive u -> Picture u
- Wumpus.Core.Picture: illustrateControlPoints :: (Real u, Floating u) => DRGB -> Primitive u -> Picture u
+ Wumpus.Core.Picture: illustrateControlPoints :: (Real u, Floating u, FromPtSize u) => DRGB -> Primitive u -> Picture u
Files
- CHANGES +22/−0
- demo/FontMetrics.hs +4/−4
- demo/LabelPic.hs +3/−3
- doc-src/Guide.lhs +5/−0
- doc/Guide.pdf binary
- src/Wumpus/Core.hs +7/−1
- src/Wumpus/Core/FontSize.hs +38/−26
- src/Wumpus/Core/Geometry.hs +13/−6
- src/Wumpus/Core/GraphicsState.hs +20/−9
- src/Wumpus/Core/OutputPostScript.hs +2/−2
- src/Wumpus/Core/OutputSVG.hs +3/−1
- src/Wumpus/Core/Picture.hs +16/−13
- src/Wumpus/Core/PictureInternal.hs +3/−2
- src/Wumpus/Core/PtSize.hs +57/−0
- src/Wumpus/Core/VersionNumber.hs +2/−2
- wumpus-core.cabal +19/−47
CHANGES view
@@ -1,4 +1,26 @@ +0.22.0 TO 0.23.0:+ + * @Basic.GraphicsState@ - extracted the font face fields from + @FontAttr@ datatype into a separate datatype @FontFace@.+ + * Added @PtSize@ a numeric type wrapping Double. This is + specifically for text size calculations, vis the + @Core.FontSize@ module.++ * Changed all functions in @Core.FontSize@ to return @PtSize@+ instead of a polymorphic type @u@ (where @u@ is an instance + of Fractional). To get to another unit type rather than + FontSize use an explicit conversion that scales the value + accordingly.++ * Added FromPtSize class constraints to various functions in+ @Core.Picture@.++ * Added @charWidth@ to @Core.FontSize@.++ * Added @vlength@ to @Core.Geometry@+ 0.21.0 to 0.22.0: * Moved the deprecated module @Wumpus.Extra.PictureLanguage@
demo/FontMetrics.hs view
@@ -28,7 +28,7 @@ black = RGB3 0 0 0 courier_attr :: FontAttr-courier_attr = FontAttr "Courier" "Courier New" SVG_REGULAR 48+courier_attr = FontAttr 48 (FontFace "Courier" "Courier New" SVG_REGULAR) metrics_pic :: DPicture metrics_pic = char_pic `picOver` lines_pic@@ -55,7 +55,7 @@ type PrimF = DPoint2 -> DPrimitive bodyHeight :: PrimF-bodyHeight = vertLine peru courier48_numeral_height+bodyHeight = vertLine peru $ fromPtSize courier48_numeral_height agraveU :: PrimF agraveU = textlabel (black, courier_attr) "&#Agrave"@@ -67,9 +67,9 @@ vertLine :: DRGB -> Double -> DPoint2 -> DPrimitive vertLine rgb height pt = ostroke rgb $ vertexPath [pt, pt .+^ vvec height] -haxis :: DRGB -> Double -> DPrimitive+haxis :: DRGB -> PtSize -> DPrimitive haxis rgb ypos = ostroke (rgb, dash_attr) $ vertexPath [ pt, pt .+^ hvec 440 ] where dash_attr = DashPattern (Dash 0 [(2,2)])- pt = P2 0 ypos+ pt = P2 0 (fromPtSize ypos)
demo/LabelPic.hs view
@@ -11,7 +11,7 @@ -drawBounds :: (Floating u, Real u) => Picture u -> Picture u+drawBounds :: (Floating u, Real u, FromPtSize u) => Picture u -> Picture u drawBounds p = p `picOver` (frame $ cstroke () ph) where ph = vertexPath $ [bl,br,tr,tl]@@ -44,7 +44,7 @@ lbl1 = line1 `picBeside` line2 where line1 = frame (textlabel attrs "Hello" zeroPt) line2 = frame (textlabel attrs "World" zeroPt)- attrs = (peru, FontAttr "Helvetica" "Helvetica" SVG_REGULAR 12) + attrs = (peru, FontAttr 12 (FontFace "Helvetica" "Helvetica" SVG_REGULAR)) demo01 :: IO ()@@ -93,7 +93,7 @@ bigLetter :: PSRgb -> Char -> Picture Double bigLetter col ch = uniformScale 5 $ frame $ textlabel attrs [ch] zeroPt where- attrs = (col, FontAttr "Helvetica" "Helvetica" SVG_REGULAR 12) + attrs = (col, FontAttr 12 (FontFace "Helvetica" "Helvetica" SVG_REGULAR)) -- | A should be above B, above T
doc-src/Guide.lhs view
@@ -101,6 +101,11 @@ width, etc. - may be specified or not. The technique is due to Iavor S. Diatchki's XML-Light. +\item[\texttt{Wumpus.Core.PtSize.}] +Text size calculations in \texttt{Core.FontSize} use points +(i.e. 1/72 of an inch). The \texttt{PtSize} module is a numeric +type to represent them. + \item[\texttt{Wumpus.Core.TextEncoder.}] Types for handling non-ASCII character codes. This module is perhaps under-cooked although it appears adequate for Latin-1.
doc/Guide.pdf view
binary file changed (56794 → 57135 bytes)
src/Wumpus/Core.hs view
@@ -34,6 +34,8 @@ -- -- * "Wumpus.Core.PictureLanguage" --+-- * "Wumpus.Core.PtSize"+-- -- * "Wumpus.Core.TextEncoder" -- -- * "Wumpus.Core.VersionNumber"@@ -42,7 +44,9 @@ -- -- Named colours ( black, white etc.) are hidden from -- "Wumpus.Core.Colour" to avoid collisions with modules that--- define colour sets (e.g. all the SVG colours). +-- define colour sets (e.g. all the SVG colours). If needed, +-- the module can be imported directly.+-- -- -- --------------------------------------------------------------------------------@@ -59,6 +63,7 @@ , module Wumpus.Core.OutputPostScript , module Wumpus.Core.OutputSVG , module Wumpus.Core.Picture+ , module Wumpus.Core.PtSize , module Wumpus.Core.TextEncoder , module Wumpus.Core.VersionNumber , module Wumpus.Core.WumpusTypes@@ -74,6 +79,7 @@ import Wumpus.Core.OutputPostScript import Wumpus.Core.OutputSVG import Wumpus.Core.Picture+import Wumpus.Core.PtSize import Wumpus.Core.TextEncoder import Wumpus.Core.VersionNumber import Wumpus.Core.WumpusTypes
src/Wumpus/Core/FontSize.hs view
@@ -44,6 +44,7 @@ -- * Metrics calculation , widthAt48pt+ , charWidth , textWidth , textHeight , numeralHeight@@ -55,9 +56,12 @@ import Wumpus.Core.BoundingBox import Wumpus.Core.Geometry+import Wumpus.Core.PtSize import Data.AffineSpace -- package: vector-space ++ type CharCount = Int type FontSize = Int @@ -72,15 +76,15 @@ -- -- > width = 26.0 ---courier48_width :: Num u => u-courier48_width = 26+courier48_width :: PtSize+courier48_width = 26.0 -- | The point size of a character in Courier at 48 pt. -- -- \*\* Naturally the height is 48.0 \*\*. ---courier48_height :: Num u => u-courier48_height = 48+courier48_height :: PtSize +courier48_height = 48.0 @@ -92,8 +96,8 @@ -- -- > numeral_height = 30.0 ---courier48_numeral_height :: Num u => u -courier48_numeral_height = 30+courier48_numeral_height :: PtSize +courier48_numeral_height = 30.0 -- | The height of the body of a lower-case letter -- (typically the letter \'x\') in Courier at 48 pt. @@ -102,16 +106,16 @@ -- -- > xheight = 20.0 -- -courier48_xheight :: Num u => u -courier48_xheight = 20+courier48_xheight :: PtSize+courier48_xheight = 20.0 -- | The depth of a descender in Courier at 48 pt. -- -- > descender_depth = 9.0 -- -courier48_descender_depth :: Num u => u -courier48_descender_depth = 9+courier48_descender_depth :: PtSize+courier48_descender_depth = 9.0 -- | The depth of an ascender in Courier at 48 pt. -- @@ -127,8 +131,8 @@ -- -- > xheight + ascender_height == numeral_height ---courier48_ascender_height :: Num u => u -courier48_ascender_height = 10+courier48_ascender_height :: PtSize +courier48_ascender_height = 10.0 -- | The spacing between letters printed directly with @@ -139,50 +143,58 @@ -- -- > spacer_width = 3.0 ---courier48_spacer_width :: Num u => u-courier48_spacer_width = 3+courier48_spacer_width :: PtSize+courier48_spacer_width = 3.0 -- | Width of the supplied string when printed at 48pt. ---widthAt48pt :: Fractional u => CharCount -> u-widthAt48pt n = courier48_width * len + courier48_spacer_width * len_sub+-- (i.e. n chars + (n-1) spacers)+--+widthAt48pt :: CharCount -> PtSize+widthAt48pt n = (courier48_width * len) + (courier48_spacer_width * len_sub) where len = fromIntegral n len_sub = len - 1.0 +-- | Approximate the width of a monospace character using +-- metrics derived from the Courier font.+--+charWidth :: FontSize -> PtSize+charWidth sz = (fromIntegral sz)/48 * courier48_width+ -- | Text width at @sz@ point size of the string @s@. All -- characters are counted literally - special chars may cause -- problems (this a current deficiency of Wumpus). ---textWidth :: Fractional u => FontSize -> CharCount -> u+textWidth :: FontSize -> CharCount -> PtSize textWidth sz n = (fromIntegral sz)/48 * widthAt48pt n -- | Text height is just identity/double-coercion of the Point size. -- i.e. @18 == 18.0@. The /size/ of a font is the maximum height: ---textHeight :: Num u => FontSize -> u+textHeight :: FontSize -> PtSize textHeight = fromIntegral -- | Approximate the height of a numeral using metrics derived -- from the Courier monospaced font. ---numeralHeight :: Fractional u => FontSize -> u+numeralHeight :: FontSize -> PtSize numeralHeight sz = textHeight sz * (courier48_numeral_height / courier48_height) -- | Approximate the height of the lower-case char \'x\' using -- metrics derived from the Courier monospaced font. ---xcharHeight :: Fractional u => FontSize -> u+xcharHeight :: FontSize -> PtSize xcharHeight sz = textHeight sz * (courier48_xheight / courier48_height) -- | Approximate the descender depth for font size @sz@ using -- metrics derived from the Courier monospaced font. -- -descenderDepth :: Fractional u => FontSize -> u-descenderDepth sz = (fromIntegral sz) / 48 * courier48_descender_depth+descenderDepth :: FontSize -> PtSize+descenderDepth sz = (fromIntegral sz) / 48 * courier48_descender_depth -- | Find the bounding box for the character count at the -- supplied font-size.@@ -197,12 +209,12 @@ -- For variable width fonts the calculated bounding box will -- usually be too long. ---textBounds :: (Fractional u, Ord u) +textBounds :: (Fractional u, Ord u, FromPtSize u) => FontSize -> Point2 u -> CharCount -> BoundingBox u textBounds sz body_bl n = bbox bl tr where- h = textHeight sz- w = textWidth sz n- dd = descenderDepth sz+ h = fromPtSize $ textHeight sz+ w = fromPtSize $ textWidth sz n+ dd = fromPtSize $ descenderDepth sz bl = body_bl .-^ V2 0 dd tr = bl .+^ V2 w h
src/Wumpus/Core/Geometry.hs view
@@ -50,11 +50,12 @@ -- * Vector operations , vec- , direction , hvec , vvec , avec , pvec+ , direction+ , vlength , vangle -- * Point operations@@ -433,11 +434,6 @@ vec :: Num u => u -> u -> Vec2 u vec = V2 --- | Direction of a vector - i.e. the counter-clockwise angle --- from the x-axis.----direction :: (Floating u, Real u) => Vec2 u -> Radian-direction (V2 x y) = langle (P2 0 0) (P2 x y) -- | Construct a vector with horizontal displacement. --@@ -464,6 +460,17 @@ -- pvec :: Num u => Point2 u -> Point2 u -> Vec2 u pvec = flip (.-.)++-- | Direction of a vector - i.e. the counter-clockwise angle +-- from the x-axis.+--+direction :: (Floating u, Real u) => Vec2 u -> Radian+direction (V2 x y) = langle (P2 0 0) (P2 x y)++-- | Length of a vector.+--+vlength :: Floating u => Vec2 u -> u+vlength (V2 x y) = sqrt $ x*x + y*y -- | Extract the angle between two vectors. --
src/Wumpus/Core/GraphicsState.hs view
@@ -56,6 +56,7 @@ -- ** Font , FontAttr(..)+ , FontFace(..) , SVGFontStyle(..) -- ** Colour@@ -106,7 +107,7 @@ deriving (Eq,Show) --- | Font name and size. Equivalent fonts have different names+-- | Font face and size. Equivalent fonts have different names -- in PostScript and SVG. A PostScript font name includes the -- font style (e.g. @Times-BoldItalic@) whereas an SVG font has -- a name (the @font-family@ attribute) and a style.@@ -121,19 +122,29 @@ -- -- See the PostScript Language Reference Manual. ---data FontAttr = FontAttr { - font_name :: String, -- for PostScript- svg_font_family :: String, -- for SVG- svg_font_style :: SVGFontStyle,- font_size :: Int - }- deriving (Eq,Show)+data FontAttr = FontAttr + { font_size :: Int + , font_face :: FontFace+ }+ deriving (Eq,Ord,Show) +-- | 'FontFace' : @ postscript_name * svg_font_family * svg_font_style @+--+data FontFace = FontFace+ { font_name :: String -- for PostScript+ , svg_font_family :: String -- for SVG+ , svg_font_style :: SVGFontStyle+ }+ deriving (Eq,Ord,Show)+++ -- | SVG font styles - potentially a style may generate both -- @font-weight@ and @font-style@ attributes in the SVG output.+-- data SVGFontStyle = SVG_REGULAR | SVG_BOLD | SVG_ITALIC | SVG_BOLD_ITALIC | SVG_OBLIQUE | SVG_BOLD_OBLIQUE- deriving (Eq,Show)+ deriving (Eq,Ord,Show) type PSRgb = RGB3 Double
src/Wumpus/Core/OutputPostScript.hs view
@@ -227,8 +227,8 @@ fontCommand :: FontAttr -> WumpusM ()-fontCommand (FontAttr name _ _ sz) = do- ps_findfont name+fontCommand (FontAttr sz face) = do+ ps_findfont (font_name face) ps_scalefont sz ps_setfont
src/Wumpus/Core/OutputSVG.hs view
@@ -174,13 +174,15 @@ -- label :: (Real u, Floating u, PSUnit u) => LabelProps -> Label u -> SvgM Element-label (c,FontAttr _ fam style sz) (Label pt entxt ctm) = do +label (c,FontAttr sz face) (Label pt entxt ctm) = do str <- encodedText entxt let tspan_elt = element_tspan str `snoc_attrs` [ attr_fill c ] return $ element_text tspan_elt `snoc_attrs` coord_attrs `snoc_attrs` font_attrs `snoc_attrs` (fontStyle style) where+ style = svg_font_style face+ fam = svg_font_family face coord_attrs = if ctm == identityCTM then simpleLabelAttrs pt else transfLabelAttrs pt ctm font_attrs = [ attr_font_family fam
src/Wumpus/Core/Picture.hs view
@@ -71,6 +71,7 @@ import Wumpus.Core.GraphicsState import Wumpus.Core.OneList import Wumpus.Core.PictureInternal+import Wumpus.Core.PtSize import Wumpus.Core.TextEncodingInternal import Data.Semigroup@@ -102,7 +103,7 @@ -- | Lift a 'Primitive' to a 'Picture', located in the standard frame. ---frame :: (Real u, Floating u) => Primitive u -> Picture u+frame :: (Real u, Floating u, FromPtSize u) => Primitive u -> Picture u frame p = Single (stdFrame, boundary p) p -- | Frame a picture within the supplied bounding box@@ -119,7 +120,7 @@ -- ellipse. Thus the bounding box will never reframed to a -- smaller size than the /natural/ bounding box. ---frameWithin :: (Real u, Floating u) +frameWithin :: (Real u, Floating u, FromPtSize u) => Primitive u -> BoundingBox u -> Picture u frameWithin p@(PLabel _ _) bb = Single (stdFrame,bb) p frameWithin p bb = Single (stdFrame,bb `append` boundary p) p@@ -135,7 +136,7 @@ -- -- This function throws an error when supplied the empty list. ---frameMulti :: (Real u, Floating u) +frameMulti :: (Real u, Floating u, FromPtSize u) => [Primitive u] -> Picture u frameMulti [] = error "Wumpus.Core.Picture.frameMulti - empty list" frameMulti xs = multi $ map frame xs@@ -200,18 +201,19 @@ -- | Constant for the default font, which is @Courier@ (aliased --- to @Courier New@ for SVG).--- --- The font size is 24 point. Note that only a handful of font --- sizes are available directly to PostScript / GhostScript.+-- to @Courier New@ for SVG) at 24 point. ----- To get non-standard sizes, consider drawing the text and --- applying a 'uniformScale'. -- wumpus_default_font :: FontAttr-wumpus_default_font = FontAttr "Courier" "Courier New" SVG_REGULAR 24+wumpus_default_font = FontAttr 24 face + where+ face = FontFace { font_name = "Courier"+ , svg_font_family = "Courier New"+ , svg_font_style = SVG_REGULAR+ } + -------------------------------------------------------------------------------- -- Take Paths to Primitives @@ -531,7 +533,8 @@ -- Draw the picture on top of an image of its bounding box. -- The bounding box image will be drawn in the supplied colour. ---illustrateBounds :: (Real u, Floating u) => DRGB -> Picture u -> Picture u+illustrateBounds :: (Real u, Floating u, FromPtSize u) + => DRGB -> Picture u -> Picture u illustrateBounds rgb p = p `picOver` (frameMulti $ boundsPrims rgb p) @@ -542,7 +545,7 @@ -- -- The result will be lifted from Primitive to Picture. -- -illustrateBoundsPrim :: (Real u, Floating u) +illustrateBoundsPrim :: (Real u, Floating u, FromPtSize u) => DRGB -> Primitive u -> Picture u illustrateBoundsPrim rgb p = frameMulti (boundsPrims rgb p ++ [p]) @@ -573,7 +576,7 @@ -- curves - they are implemented with PostScript\'s -- @arc@ command. ---illustrateControlPoints :: (Real u, Floating u)+illustrateControlPoints :: (Real u, Floating u, FromPtSize u) => DRGB -> Primitive u -> Picture u illustrateControlPoints rgb prim = step prim where
src/Wumpus/Core/PictureInternal.hs view
@@ -73,6 +73,7 @@ import Wumpus.Core.Geometry import Wumpus.Core.GraphicsState import Wumpus.Core.OneList+import Wumpus.Core.PtSize import Wumpus.Core.TextEncodingInternal import Wumpus.Core.Utils @@ -599,14 +600,14 @@ -- Note - this will calculate an approximate bounding box for -- text. -instance (Real u, Floating u) => Boundary (Primitive u) where+instance (Real u, Floating u, FromPtSize u) => Boundary (Primitive u) where boundary (PPath _ p) = boundary p boundary (PLabel (_,a) l) = primLabelBoundary a l boundary (PEllipse _ e) = boundary e -primLabelBoundary :: (Floating u, Real u) +primLabelBoundary :: (Floating u, Real u, FromPtSize u) => FontAttr -> Label u -> BoundingBox u primLabelBoundary attr (Label (P2 x y) xs ctm) = retraceBoundary (disp . (m33 *#)) untraf_bbox
+ src/Wumpus/Core/PtSize.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# OPTIONS -Wall #-}++--------------------------------------------------------------------------------+-- |+-- Module : Wumpus.Core.PtSize+-- Copyright : (c) Stephen Tetley 2010+-- License : BSD3+--+-- Maintainer : stephen.tetley@gmail.com+-- Stability : unstable+-- Portability : GHC with TypeFamilies and more+--+-- Numeric type representing Point size (1/72 inch) which is +-- PostScript and Wumpus-Core\'s internal unit size.+--+-- Other unit types (e.g. centimeter) should define an +-- appropriate instance of FromPtSize.+-- +--------------------------------------------------------------------------------++module Wumpus.Core.PtSize+ ( + + -- * Point size type+ PtSize+ + -- * Extract (unscaled) PtSize as a Double + , ptSize++ -- * Conversion class+ , FromPtSize(..)++ ) where+++-- | Wumpus-Core +newtype PtSize = PtSize { ptSize :: Double } + deriving (Eq,Ord,Num,Floating,Fractional)++instance Show PtSize where+ showsPrec p d = showsPrec p (ptSize d)+++-- | Convert the value of PtSize scaling accordingly.+--+-- Note - the Double instance perfoms no scaling, this+-- is because internally Wumpus-Core works in points.+-- +class FromPtSize u where+ fromPtSize :: PtSize -> u++instance FromPtSize Double where+ fromPtSize = ptSize+++
src/Wumpus/Core/VersionNumber.hs view
@@ -22,7 +22,7 @@ -- | Version number ----- > (0,22,0)+-- > (0,23,0) -- wumpus_core_version :: (Int,Int,Int)-wumpus_core_version = (0,22,0)+wumpus_core_version = (0,23,0)
wumpus-core.cabal view
@@ -1,5 +1,5 @@ name: wumpus-core-version: 0.22.0+version: 0.23.0 license: BSD3 license-file: LICENSE copyright: Stephen Tetley <stephen.tetley@gmail.com>@@ -50,10 +50,7 @@ not offer distinct functionality. Some functions were removed in revision 0.17.0 and some more are likely to follow. .- The module @Extra.PictureLanguage@ is deprecated. At some point - it will be superceded by @wumpus-basic@ but this will not be soon. .- . \[1\] Because the output is simple, straight-line PostScript code, it is possible to use GraphicsMagick or a similar tool to convert Wumpus'\s EPS files to many other formats @@ -61,53 +58,27 @@ . Changelog: .- 0.21.0 to 0.22.0:- .- * Moved the deprecated module @Wumpus.Extra.PictureLanguage@- into the package Wumpus-Basic along with the example - @Picture.hs@.- .- * Added vec as a synonym for the constructor V2.- .- * Changed some of the Core.FontSize to use better terminology. - Thus some of the constants have changed. Added a new example- @FontMetrics.hs@ to illustrate how FontSize works. - Particularly, the function @capHeight@ has been replaced with- the function @numeralHeight@ which has better semantics.- .- * The CTM data type and ToCTM class are now hidden in the- top-level import module @Wumpus.Core@. They can be accessed- by importing @Wumpus.Core.GraphicsState@ directly.- .- * Exposed the PSUnit type class. - .- 0.20.0 to 0.21.0:+ 0.22.0 TO 0.23.0:+ . + * @Basic.GraphicsState@ - extracted the font face fields from + @FontAttr@ datatype into a separate datatype @FontFace@.+ . + * Added @PtSize@ a numeric type wrapping Double. This is + specifically for text size calculations, vis the + @Core.FontSize@ module. .- * Removed the Primitive instances of the Affine transformation - classes. They have been replaced with special transformation - functions: @rotatePrimitive@, @scalePrimitive@, - @translatePrimitive@. As Primitives are not in an affine - frame until they are lifted to Pictures the affine instances - had ill-conceived semantics.+ * Changed all functions in @Core.FontSize@ to return @PtSize@+ instead of a polymorphic type @u@ (where @u@ is an instance + of Fractional). To get to another unit type rather than + FontSize use an explicit conversion that scales the value + accordingly. .- * Due to changes to accommodate the new non-affine - transformations, many of the class obligations have changed - on the @unit@ of Pictures, Primitives, Bounding Boxes etc. - Generally many class contexts that previously required - Fractional and Ord on the unit have changed to Real and - Floating.+ * Added FromPtSize class constraints to various functions in+ @Core.Picture@. .- * Removed demo/AffineTest04.hs - there is no longer a - @rotateAbout@ operation on Primitives as they do not exist - in an affine frame until they they are lifted to Pictures.- Added - Scaled.hs, Rotated.hs, Translated,hs.- . - * Removed the UndecidableInstances pragma from - Core.PictureInternal. It looks like Core.Geometry will always - need UndecidableInstances though.+ * Added @charWidth@ to @Core.FontSize@. .- * Removed the Ord superclass constriant from the @Stroke@ and- @Fill@ classes and derived operations (e.g. @zostroke@).+ * Added @vlength@ to @Core.Geometry@ . . build-type: Simple@@ -152,6 +123,7 @@ Wumpus.Core.OutputPostScript, Wumpus.Core.OutputSVG, Wumpus.Core.Picture,+ Wumpus.Core.PtSize, Wumpus.Core.TextEncoder, Wumpus.Core.TextLatin1, Wumpus.Core.VersionNumber,