packages feed

codeworld-api 0.1.0.1 → 0.2.0.0

raw patch · 4 files changed

+19/−44 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- CodeWorld: line :: [Point] -> Picture
- CodeWorld: pictureOf :: Picture -> IO ()
- CodeWorld: thickLine :: Double -> [Point] -> Picture

Files

codeworld-api.cabal view
@@ -1,5 +1,5 @@ Name:                codeworld-api-Version:             0.1.0.1+Version:             0.2.0.0 Synopsis:            Graphics library for CodeWorld License:             Apache License-file:        LICENSE
src/CodeWorld.hs view
@@ -17,7 +17,6 @@ module CodeWorld (     -- * Entry points     drawingOf,-    pictureOf,     animationOf,     simulationOf,     interactionOf,@@ -27,8 +26,6 @@     TextStyle(..),     Font(..),     blank,-    line,-    thickLine,     path,     thickPath,     polygon,@@ -57,8 +54,8 @@     dilated,     rotated,     pictures,-    (&),     (<>),+    (&),     coordinatePlane,     codeWorldLogo,     Point,
src/CodeWorld/Driver.hs view
@@ -25,7 +25,6 @@  module CodeWorld.Driver (     drawingOf,-    pictureOf,     animationOf,     simulationOf,     interactionOf,@@ -90,10 +89,6 @@ -- | Draws a `Picture`.  This is the simplest CodeWorld entry point. drawingOf :: Picture -> IO () --- | Draws a `Picture`.  This is the simplest CodeWorld entry point.-pictureOf :: Picture -> IO ()-{-# WARNING pictureOf "Please use drawingOf instead of pictureOf" #-}- -- | Shows an animation, with a picture for each time given by the parameter. animationOf :: (Double -> Picture) -> IO () @@ -362,9 +357,7 @@  drawingOf pic = display pic `catch` reportError -pictureOf pic = display pic `catch` reportError - -------------------------------------------------------------------------------- -- Stand-alone implementation of drawing @@ -496,14 +489,12 @@ drawPicture ds (Rotate r p)      = drawPicture (rotateDS r ds) p drawPicture ds (Pictures ps)     = mapM_ (drawPicture ds) (reverse ps) -drawFrame :: Picture -> Canvas ()-drawFrame pic = do-    Canvas.fillStyle "white"-    Canvas.fillRect (-250, -250, 500, 500)-    drawPicture initialDS pic- setupScreenContext :: (Int, Int) -> Canvas () setupScreenContext (cw, ch) = do+    -- blank before transformation (canvas might be non-sqare)+    Canvas.fillStyle "white"+    Canvas.fillRect (0,0,fromIntegral cw,fromIntegral ch)+     Canvas.translate (realToFrac cw / 2, realToFrac ch / 2)     let s = min (realToFrac cw / 500) (realToFrac ch / 500)     Canvas.scale (s, -s)@@ -527,9 +518,7 @@     Canvas.send context $ Canvas.saveRestore $ do         let rect = (Canvas.width context, Canvas.height context)         setupScreenContext rect-        drawFrame pic--pictureOf = drawingOf+        drawPicture initialDS pic  drawingOf pic = display pic `catch` reportError #endif@@ -759,7 +748,7 @@                 Canvas.with offscreenCanvas $                     Canvas.saveRestore $ do                         setupScreenContext rect-                        drawFrame (activityDraw a0)+                        drawPicture initialDS (activityDraw a0)             tn <- getCurrentTime              threadDelay $ max 0 (50000 - (round ((tn `diffUTCTime` t0) * 1000000)))
src/CodeWorld/Picture.hs view
@@ -68,16 +68,6 @@ thickPath :: Double -> [Point] -> Picture thickPath n ps = Path ps n False False --- | A thin sequence of line segments, with these points as endpoints-line :: [Point] -> Picture-line ps = Path ps 0 False False-{-# WARNING line "Please use path instead of line" #-}---- | A thick sequence of line segments, with this line width and endpoints-thickLine :: Double -> [Point] -> Picture-thickLine n ps = Path ps n False False-{-# WARNING thickLine "Please use thickPath instead of thickLine" #-}- -- | A thin polygon with these points as vertices polygon :: [Point] -> Picture polygon ps = Path ps 0 True False@@ -198,28 +188,27 @@ pictures :: [Picture] -> Picture pictures = Pictures --- Binary composition of pictures.+instance Monoid Picture where+  mempty                  = blank+  mappend a (Pictures bs) = Pictures (a:bs)+  mappend a b             = Pictures [a, b]+  mconcat                 = pictures++-- | Binary composition of pictures. (&) :: Picture -> Picture -> Picture infixr 0 &-a & Pictures bs = Pictures (a:bs)-a & b           = Pictures [a, b]-{-# WARNING (&) "Please use <> from Data.Monoid instead of &" #-}--instance Monoid Picture where-  mempty = blank-  mappend = (&)-  mconcat = pictures+(&) = mappend  -- | A coordinate plane.  Adding this to your pictures can help you measure distances -- more accurately. -- -- Example: -----    main = pictureOf(myPicture & coordinatePlane)+--    main = pictureOf (myPicture <> coordinatePlane) --    myPicture = ... coordinatePlane :: Picture-coordinatePlane = axes & numbers & guidelines-  where xline y     = line [(-10, y), (10, y)]+coordinatePlane = axes <> numbers <> guidelines+  where xline y     = path [(-10, y), (10, y)]         xaxis       = colored (RGBA 0 0 0 0.75) (xline 0)         axes        = xaxis <> rotated (pi/2) xaxis         xguidelines = pictures