packages feed

hoodle-types 0.1.0 → 0.1.1

raw patch · 5 files changed

+59/−8 lines, 5 filesdep ~lensPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: lens

API changes (from Hackage documentation)

+ Data.Hoodle.BBox: SVGBBox :: SVG -> BBox -> SVGBBox
+ Data.Hoodle.BBox: bboxFromSVG :: SVG -> BBox
+ Data.Hoodle.BBox: data SVGBBox
+ Data.Hoodle.BBox: instance BBoxable SVGBBox
+ Data.Hoodle.BBox: instance Eq SVGBBox
+ Data.Hoodle.BBox: instance Ord SVGBBox
+ Data.Hoodle.BBox: instance Serialize SVGBBox
+ Data.Hoodle.BBox: instance Show SVGBBox
+ Data.Hoodle.BBox: mkSVGBBox :: SVG -> SVGBBox
+ Data.Hoodle.BBox: svgbbx_bbx :: SVGBBox -> BBox
+ Data.Hoodle.BBox: svgbbx_svg :: SVGBBox -> SVG
+ Data.Hoodle.Predefined: getPenColor :: ByteString -> Maybe (Double, Double, Double, Double)
+ Data.Hoodle.Simple: ItemSVG :: SVG -> Item
+ Data.Hoodle.Simple: SVG :: Maybe ByteString -> Maybe ByteString -> ByteString -> (Double, Double) -> !Dimension -> SVG
+ Data.Hoodle.Simple: data SVG
+ Data.Hoodle.Simple: instance Eq SVG
+ Data.Hoodle.Simple: instance Ord SVG
+ Data.Hoodle.Simple: instance Serialize SVG
+ Data.Hoodle.Simple: instance Show SVG
+ Data.Hoodle.Simple: svg_command :: SVG -> Maybe ByteString
+ Data.Hoodle.Simple: svg_dim :: SVG -> !Dimension
+ Data.Hoodle.Simple: svg_pos :: SVG -> (Double, Double)
+ Data.Hoodle.Simple: svg_render :: SVG -> ByteString
+ Data.Hoodle.Simple: svg_text :: SVG -> Maybe ByteString

Files

LICENSE view
@@ -1,7 +1,7 @@ The following license covers this documentation, and the source code, except where otherwise indicated. -Copyright 2011, Ian-Woo Kim. All rights reserved.+Copyright 2011-2013, Ian-Woo Kim. All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
hoodle-types.cabal view
@@ -1,5 +1,5 @@ Name:		hoodle-types-Version:	0.1.0+Version:	0.1.1 Synopsis:	Data types for programs for hoodle file format Description: 	Hoodle file format data type including generic interface License: 	BSD3@@ -24,7 +24,7 @@                    bytestring >= 0.9,                     strict == 0.3.*,                     containers >= 0.4, -                   lens >= 2.4,+                   lens >= 2.5,                    TypeCompose == 0.9.*,                     cereal == 0.3.*    Exposed-Modules: 
src/Data/Hoodle/BBox.hs view
@@ -23,10 +23,13 @@ -- , imgbbx_img -- , imgbbx_bbx , mkImageBBox+, SVGBBox (..)+, mkSVGBBox , mkbbox , mkbboxF , bboxFromStroke , bboxFromImage+, bboxFromSVG , dimToBBox , bboxToDim , xformBBox@@ -113,7 +116,29 @@             }   +-- | +data SVGBBox = SVGBBox { svgbbx_svg :: SVG+                       , svgbbx_bbx :: BBox } +               deriving (Show,Eq,Ord)+  +instance BBoxable SVGBBox where+  getBBox = svgbbx_bbx+ -- |+instance Serialize SVGBBox where+  put SVGBBox{..} = put svgbbx_svg >> put svgbbx_bbx+  get = SVGBBox <$> get <*> get+  +-- | smart constructor for ImageBBox +mkSVGBBox :: SVG -> SVGBBox+mkSVGBBox svg = +  SVGBBox { svgbbx_svg = svg+          , svgbbx_bbx = bboxFromSVG svg+          } ++++-- | mkbbox :: [Pair Double Double] -> BBox  mkbbox lst = let xs = map fst lst                   ys = map snd lst@@ -149,6 +174,11 @@ -- |  bboxFromImage :: Image -> BBox  bboxFromImage (Image _ (x,y) d) = moveBBoxULCornerTo (x,y) (dimToBBox d)    +++-- | +bboxFromSVG :: SVG -> BBox +bboxFromSVG (SVG _ _ _ (x,y) d) = moveBBoxULCornerTo (x,y) (dimToBBox d)       -- | general transform BBox         
src/Data/Hoodle/Predefined.hs view
@@ -35,7 +35,7 @@  rgbaToHEX :: (Double,Double,Double,Double) -> String rgbaToHEX (r,g,b,a) = -  let i :: Integer = round (255*a) + round (256*255*b) + round (256*256*255*g) + round (256*256*256*255*r) +  let i :: Integer = floor (255*a) + 256*floor (255*b) + 256*256*floor (255*g) + 256*256*256*floor (255*r)    in printf "#%08x" i  predefined_highlighter_opacity :: Double @@ -55,13 +55,15 @@              , ("yellow"    , hexToRGBA 0xffff00ff)              , ("white"     , hexToRGBA 0xffffffff) ]  -{-+-- | need to be refined.  getPenColor :: B.ByteString -> Maybe (Double,Double,Double,Double)  getPenColor b | (not . B.null) b =    case B.head b of -    '#' -> B.tail b --}+    '#' -> Just (hexToRGBA . (read  :: String -> Integer) . B.unpack $ ("0x" `B.append` (B.tail b) ))+    _ -> M.lookup b predefined_pencolor +getPenColor _ | otherwise = Nothing  +-- |  predefined_bkgcolor :: M.Map B.ByteString (Double,Double,Double,Double) predefined_bkgcolor =    M.fromList [ (""      , hexToRGBA 0xffffffff) 
src/Data/Hoodle/Simple.hs view
@@ -34,6 +34,7 @@ -- | wrapper of object embeddable in Layer data Item = ItemStroke Stroke           | ItemImage Image+          | ItemSVG SVG           deriving (Show,Eq,Ord)  @@ -56,7 +57,12 @@                    }               deriving (Show,Eq,Ord) -+data SVG = SVG { svg_text :: Maybe S.ByteString+               , svg_command :: Maybe S.ByteString +               , svg_render :: S.ByteString+               , svg_pos :: (Double,Double)+               , svg_dim :: !Dimension }  +           deriving (Show,Eq,Ord)  -- |  instance SE.Serialize Stroke where@@ -83,17 +89,30 @@                      >> SE.put img_dim     get = Image <$> SE.get <*> SE.get <*> SE.get +-- | +instance SE.Serialize SVG where+    put SVG {..} = SE.put svg_text+                   >> SE.put svg_command +                   >> SE.put svg_render+                   >> SE.put svg_pos+                   >> SE.put svg_dim+    get = SVG <$> SE.get <*> SE.get <*> SE.get <*> SE.get <*> SE.get ++ -- |  instance SE.Serialize Item where     put (ItemStroke str) = SE.putWord8 0                             >> SE.put str      put (ItemImage img) = SE.putWord8 1                            >> SE.put img+    put (ItemSVG svg) = SE.putWord8 2+                        >> SE.put svg      get = do tag <- SE.getWord8               case tag of                 0 -> ItemStroke <$> SE.get                1 -> ItemImage <$> SE.get+               2 -> ItemSVG <$> SE.get                _ -> fail "err in Item parsing"  -- |