-- 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.0.0 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 the most -- advanced CodeWorld entry point. interactionOf :: world -> (Double -> world -> world) -> (Event -> world -> world) -> (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 path :: [Point] -> Picture -- | A thick sequence of line segments, with given line width and endpoints thickPath :: Double -> [Point] -> Picture -- | A thin polygon with these points as vertices polygon :: [Point] -> Picture -- | A thick polygon with this line width and these points as vertices thickPolygon :: Double -> [Point] -> Picture -- | A solid polygon with these points as vertices solidPolygon :: [Point] -> Picture -- | A smooth curve passing through these points. curve :: [Point] -> Picture -- | A thick smooth curve with this line width, passing through these -- points. thickCurve :: Double -> [Point] -> Picture -- | A smooth closed loop passing through these points. loop :: [Point] -> Picture -- | A thick smooth closed loop with this line width, passing through these -- points. thickLoop :: Double -> [Point] -> Picture -- | A solid smooth closed loop passing through these points. solidLoop :: [Point] -> Picture -- | A thin rectangle, with this width and height rectangle :: Double -> Double -> Picture -- | A solid rectangle, with this width and height solidRectangle :: Double -> Double -> Picture -- | A thick rectangle, with this line width, and width and height thickRectangle :: Double -> Double -> Double -> Picture -- | A thin circle, with this radius circle :: Double -> Picture -- | A solid circle, with this radius solidCircle :: Double -> Picture -- | A thick circle, with this line width and radius thickCircle :: Double -> Double -> Picture -- | A thin arc, starting and ending at these angles, with this radius -- -- Angles are in radians. arc :: 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 :: 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 :: Double -> Double -> Double -> Double -> Picture -- | A piece of text text :: Text -> Picture styledText :: TextStyle -> Font -> Text -> Picture -- | A picture drawn entirely in this color. colored :: Color -> Picture -> Picture -- | A picture drawn entirely in this color. coloured :: Color -> Picture -> Picture -- | A picture drawn translated in these directions. translated :: Double -> Double -> Picture -> Picture -- | A picture scaled by these factors. scaled :: Double -> Double -> Picture -> Picture -- | A picture scaled by these factors. dilated :: Double -> Double -> Picture -> Picture -- | A picture rotated by this angle. -- -- Angles are in radians. rotated :: 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 = pictureOf (myPicture <> coordinatePlane) myPicture = ... coordinatePlane :: Picture -- | The CodeWorld logo. codeWorldLogo :: Picture type Point = (Double, Double) type Vector = (Double, 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 hue :: Color -> Double saturation :: Color -> Double luminosity :: Color -> Double 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