-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Graphics library for CodeWorld -- -- This module provides the drawing code for CodeWorld. It is heavily -- inspired by Gloss, but modified for consistency and pedagogical -- reasons. -- -- It comes with two backends. When compiled with GHCJS, it uses the -- JavaScript FFI to run on http://code.world/. When compiled with -- GHC, it uses the blank-canvas package to provide a webpage consisting -- of just a panel locally. This way, the same program that runs on the -- CodeWorld server can also be run locally. @package codeworld-api @version 0.2.2.1 module CodeWorld -- | Draws a Picture. This is the simplest CodeWorld entry point. drawingOf :: Picture -> IO () -- | Shows an animation, with a picture for each time given by the -- parameter. animationOf :: (Double -> Picture) -> IO () -- | Shows a simulation, which is essentially a continuous-time dynamical -- system described by an initial value and step function. simulationOf :: world -> (Double -> world -> world) -> (world -> Picture) -> IO () -- | Runs an interactive event-driven CodeWorld program. This is a -- generalization of simulations that can respond to events like key -- presses and mouse movement. interactionOf :: world -> (Double -> world -> world) -> (Event -> world -> world) -> (world -> Picture) -> IO () -- | Runs an interactive multi-user CodeWorld program, involving multiple -- participants over the internet. collaborationOf :: Int -> StaticPtr (StdGen -> world) -> StaticPtr (Double -> world -> world) -> StaticPtr (Int -> Event -> world -> world) -> StaticPtr (Int -> world -> Picture) -> IO () -- | A version of collaborationOf that avoids static pointers, and -- does not check for consistent parameters. unsafeCollaborationOf :: Int -> (StdGen -> world) -> (Double -> world -> world) -> (Int -> Event -> world -> world) -> (Int -> world -> Picture) -> IO () data Picture data TextStyle Plain :: TextStyle Bold :: TextStyle Italic :: TextStyle data Font SansSerif :: Font Serif :: Font Monospace :: Font Handwriting :: Font Fancy :: Font NamedFont :: !Text -> Font -- | A blank picture blank :: Picture -- | A thin sequence of line segments, with these points as endpoints polyline :: HasCallStack => [Point] -> Picture -- | A thin sequence of line segments, with these points as endpoints -- | Warning: Please use polyline instead of path. path :: HasCallStack => [Point] -> Picture -- | A thick sequence of line segments, with given line width and endpoints thickPolyline :: HasCallStack => Double -> [Point] -> Picture -- | A thick sequence of line segments, with given line width and endpoints -- | Warning: Please used thickPolyline instead of thickPath. thickPath :: HasCallStack => Double -> [Point] -> Picture -- | A thin polygon with these points as vertices polygon :: HasCallStack => [Point] -> Picture -- | A thick polygon with this line width and these points as vertices thickPolygon :: HasCallStack => Double -> [Point] -> Picture -- | A solid polygon with these points as vertices solidPolygon :: HasCallStack => [Point] -> Picture -- | A smooth curve passing through these points. curve :: HasCallStack => [Point] -> Picture -- | A thick smooth curve with this line width, passing through these -- points. thickCurve :: HasCallStack => Double -> [Point] -> Picture -- | A smooth closed curve passing through these points. closedCurve :: HasCallStack => [Point] -> Picture -- | A smooth closed curve passing through these points. -- | Warning: Please use closedCurve instead of loop. loop :: HasCallStack => [Point] -> Picture -- | A thick smooth closed curve with this line width, passing through -- these points. thickClosedCurve :: HasCallStack => Double -> [Point] -> Picture -- | A thick smooth closed curve with this line width, passing through -- these points. -- | Warning: Please use thickClosedCurve instead of thickLoop. thickLoop :: HasCallStack => Double -> [Point] -> Picture -- | A solid smooth closed curve passing through these points. solidClosedCurve :: HasCallStack => [Point] -> Picture -- | A solid smooth closed curve passing through these points. -- | Warning: Please use solidClosedCurve instead of solidLoop. solidLoop :: HasCallStack => [Point] -> Picture -- | A thin rectangle, with this width and height rectangle :: HasCallStack => Double -> Double -> Picture -- | A solid rectangle, with this width and height solidRectangle :: HasCallStack => Double -> Double -> Picture -- | A thick rectangle, with this line width, and width and height thickRectangle :: HasCallStack => Double -> Double -> Double -> Picture -- | A thin circle, with this radius circle :: HasCallStack => Double -> Picture -- | A solid circle, with this radius solidCircle :: HasCallStack => Double -> Picture -- | A thick circle, with this line width and radius thickCircle :: HasCallStack => Double -> Double -> Picture -- | A thin arc, starting and ending at these angles, with this radius -- -- Angles are in radians. arc :: HasCallStack => Double -> Double -> Double -> Picture -- | A solid sector of a circle (i.e., a pie slice) starting and ending at -- these angles, with this radius -- -- Angles are in radians. sector :: HasCallStack => Double -> Double -> Double -> Picture -- | A thick arc with this line width, starting and ending at these angles, -- with this radius. -- -- Angles are in radians. thickArc :: HasCallStack => Double -> Double -> Double -> Double -> Picture -- | A piece of text text :: HasCallStack => Text -> Picture styledText :: HasCallStack => TextStyle -> Font -> Text -> Picture -- | A picture drawn entirely in this color. colored :: HasCallStack => Color -> Picture -> Picture -- | A picture drawn entirely in this colour. coloured :: HasCallStack => Color -> Picture -> Picture -- | A picture drawn translated in these directions. translated :: HasCallStack => Double -> Double -> Picture -> Picture -- | A picture scaled by these factors. scaled :: HasCallStack => Double -> Double -> Picture -> Picture -- | A picture scaled by these factors. dilated :: HasCallStack => Double -> Picture -> Picture -- | A picture rotated by this angle. -- -- Angles are in radians. rotated :: HasCallStack => Double -> Picture -> Picture pictures :: [Picture] -> Picture -- | An infix synonym for mappend. (<>) :: Monoid m => m -> m -> m infixr 6 <> -- | Binary composition of pictures. (&) :: Picture -> Picture -> Picture infixr 0 & -- | A coordinate plane. Adding this to your pictures can help you measure -- distances more accurately. -- -- Example: -- -- main = drawingOf (myPicture <> coordinatePlane) myPicture = ... coordinatePlane :: HasCallStack => Picture -- | The CodeWorld logo. codeWorldLogo :: HasCallStack => Picture type Point = (Double, Double) type Vector = (Double, Double) vectorLength :: Vector -> Double vectorDirection :: Vector -> Double vectorSum :: Vector -> Vector -> Vector vectorDifference :: Vector -> Vector -> Vector scaledVector :: Double -> Vector -> Vector -- | Angle is in radians rotatedVector :: Double -> Vector -> Vector dotProduct :: Vector -> Vector -> Double data Color RGBA :: !Double -> !Double -> !Double -> !Double -> Color type Colour = Color black :: Color white :: Color red :: Color green :: Color blue :: Color cyan :: Color magenta :: Color yellow :: Color aquamarine :: Color orange :: Color azure :: Color violet :: Color chartreuse :: Color rose :: Color brown :: Color pink :: Color purple :: Color gray :: Double -> Color grey :: Double -> Color mixed :: Color -> Color -> Color lighter :: Double -> Color -> Color light :: Color -> Color darker :: Double -> Color -> Color dark :: Color -> Color brighter :: Double -> Color -> Color bright :: Color -> Color duller :: Double -> Color -> Color dull :: Color -> Color translucent :: Color -> Color -- | An infinite list of colors. assortedColors :: [Color] hue :: Color -> Double saturation :: Color -> Double luminosity :: Color -> Double alpha :: Color -> Double -- | Warning: Please use HSL instead of fromHSL. fromHSL :: Double -> Double -> Double -> Color -- | An event initiated by the user. -- -- Values of this type represent events that the user triggers when using -- an interaction, defined with interactionOf. -- -- Key events describe the key as Text. Most keys are represented -- by a single character text string, with the capital letter or other -- symbol from the key. Keys that don't correspond to a single character -- use longer names from the following list. Keep in mind that not all of -- these keys appear on all keyboards. -- -- data Event KeyPress :: !Text -> Event KeyRelease :: !Text -> Event MousePress :: !MouseButton -> !Point -> Event MouseRelease :: !MouseButton -> !Point -> Event MouseMovement :: !Point -> Event data MouseButton LeftButton :: MouseButton MiddleButton :: MouseButton RightButton :: MouseButton -- | Prints a debug message to the CodeWorld console when a value is -- forced. This is equivalent to the similarly named function in -- Trace, except that it uses the CodeWorld console instead of -- standard output. trace :: Text -> a -> a