-- 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.5.0 module CodeWorld.Sketches sketchedAirplane :: HasCallStack => Picture sketchedClock :: HasCallStack => Picture sketchedAlien :: HasCallStack => Picture sketchedApple :: HasCallStack => Picture sketchedAstronaut :: HasCallStack => Picture sketchedBaby :: HasCallStack => Picture sketchedBalloon :: HasCallStack => Picture sketchedBall :: HasCallStack => Picture sketchedBell :: HasCallStack => Picture sketchedBird :: HasCallStack => Picture sketchedBoat :: HasCallStack => Picture sketchedBook :: HasCallStack => Picture sketchedBoy :: HasCallStack => Picture sketchedBubble :: HasCallStack => Picture sketchedBug :: HasCallStack => Picture sketchedCar :: HasCallStack => Picture sketchedChatBubble :: HasCallStack => Picture sketchedChest :: HasCallStack => Picture sketchedCloud :: HasCallStack => Picture sketchedCoin :: HasCallStack => Picture sketchedDog :: HasCallStack => Picture sketchedDragon :: HasCallStack => Picture sketchedExplosion :: HasCallStack => Picture sketchedFish :: HasCallStack => Picture sketchedFlag :: HasCallStack => Picture sketchedFlame :: HasCallStack => Picture sketchedFlower :: HasCallStack => Picture sketchedGear :: HasCallStack => Picture sketchedGhost :: HasCallStack => Picture sketchedGirl :: HasCallStack => Picture sketchedGrass :: HasCallStack => Picture sketchedHeart :: HasCallStack => Picture sketchedHotAirBalloon :: HasCallStack => Picture sketchedHouse :: HasCallStack => Picture sketchedJewel :: HasCallStack => Picture sketchedKey :: HasCallStack => Picture sketchedCat :: HasCallStack => Picture sketchedLightBulb :: HasCallStack => Picture sketchedLightning :: HasCallStack => Picture sketchedMonster :: HasCallStack => Picture sketchedMoon :: HasCallStack => Picture sketchedNote :: HasCallStack => Picture sketchedPawnBlack :: HasCallStack => Picture sketchedPawnBlue :: HasCallStack => Picture sketchedPawnGreen :: HasCallStack => Picture sketchedPawnRed :: HasCallStack => Picture sketchedPawnWhite :: HasCallStack => Picture sketchedRaindrop :: HasCallStack => Picture sketchedRobot :: HasCallStack => Picture sketchedRocket :: HasCallStack => Picture sketchedScroll :: HasCallStack => Picture sketchedSign :: HasCallStack => Picture sketchedSparkle :: HasCallStack => Picture sketchedStar :: HasCallStack => Picture sketchedSun :: HasCallStack => Picture sketchedThoughtBubble :: HasCallStack => Picture sketchedBlock :: HasCallStack => Picture sketchedTree :: HasCallStack => Picture module CodeWorld.Image -- | An image from a standard image format. The image can be any -- universally supported format, including SVG, PNG, JPG, etc. SVG should -- be preferred, as it behaves better with transformations. image :: HasCallStack => Text -> Text -> Double -> Double -> Picture -- | Module for using CodeWorld pictures in Reflex-based FRP applications. module CodeWorld.Reflex -- | The entry point for running Reflex-based CodeWorld programs. -- | Warning: Please use reactiveOf instead of reflexOf.reflexOf will be -- removed and replaced soon. reflexOf :: (forall t m. (Reflex t, MonadHold t m, MonadFix m, TriggerEvent t m, PerformEvent t m, MonadIO m, MonadIO (Performable m), Adjustable t m, NotReady t m, PostBuild t m) => ReactiveInput t -> m (Dynamic t Picture)) -> IO () data ReactiveInput t keyPress :: ReactiveInput t -> Event t Text keyRelease :: ReactiveInput t -> Event t Text textEntry :: ReactiveInput t -> Event t Text pointerPress :: ReactiveInput t -> Event t Point pointerRelease :: ReactiveInput t -> Event t Point pointerPosition :: ReactiveInput t -> Dynamic t Point pointerDown :: ReactiveInput t -> Dynamic t Bool timePassing :: ReactiveInput t -> Event t Double -- | Warning: After the current migration is complete,reactiveOf will -- probably be renamed to reflexOf. reactiveOf :: (forall t m. ReflexCodeWorld t m => m ()) -> IO () -- | Warning: After the current migration is complete,debugReactiveOf -- will probably be renamed to debugReflexOf. debugReactiveOf :: (forall t m. ReflexCodeWorld t m => m ()) -> IO () -- | Type class for the builder monad of a CodeWorld/Reflex app. class (Reflex t, Adjustable t m, MonadHold t m, NotReady t m, PostBuild t m, PerformEvent t m, TriggerEvent t m, MonadFix m, MonadIO m, MonadIO (Performable m)) => ReflexCodeWorld t m | m -> t -- | Gets an Event of key presses. The event value is a logical key name. getKeyPress :: ReflexCodeWorld t m => m (Event t Text) -- | Gets an Event of key presses. The event value is a logical key name. getKeyRelease :: ReflexCodeWorld t m => m (Event t Text) -- | Gets an Event of text entered. The event value is the typed text. getTextEntry :: ReflexCodeWorld t m => m (Event t Text) -- | Gets an event of pointer clicks. The event value is the location of -- the click. getPointerClick :: ReflexCodeWorld t m => m (Event t Point) -- | Gets the Dynamic position of the pointer. getPointerPosition :: ReflexCodeWorld t m => m (Dynamic t Point) -- | Gets a Dynamic indicator whether the pointer is held down. isPointerDown :: ReflexCodeWorld t m => m (Dynamic t Bool) -- | Gets an Event indicating the passage of time. getTimePassing :: ReflexCodeWorld t m => m (Event t Double) -- | Emits a given Dynamic picture to be drawn to the screen. draw :: ReflexCodeWorld t m => Dynamic t Picture -> m () -- | A design, diagram, or drawing that can be displayed and seen. In -- technical terms, a picture is an assignment of a color to every point -- of the coordinate plane. CodeWorld contains functions to create -- pictures from simple geometry primitives, to transform existing -- pictures, and to combine simpler pictures into more complex -- compositions. -- -- Ultimately, a picture can be drawn on the screen using one of the -- CodeWorld entry points such as drawingOf. data Picture -- | A blank picture blank :: HasCallStack => Picture -- | A thin sequence of line segments, with these points as endpoints polyline :: HasCallStack => [Point] -> Picture -- | A thick sequence of line segments, with given line width and endpoints thickPolyline :: 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 thick smooth closed curve with this line width, passing through -- these points. thickClosedCurve :: HasCallStack => Double -> [Point] -> Picture -- | A solid smooth closed curve passing through these points. solidClosedCurve :: 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 rendering of text characters. lettering :: HasCallStack => Text -> Picture data TextStyle -- | Plain letters with no style Plain :: TextStyle -- | Heavy, thick lettering used for emphasis Bold :: TextStyle -- | Slanted script-like lettering used for emphasis Italic :: TextStyle data Font SansSerif :: Font Serif :: Font Monospace :: Font Handwriting :: Font Fancy :: Font NamedFont :: !Text -> Font -- | A rendering of text characters onto a Picture, with a specific choice -- of font and style. styledLettering :: 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 in the x and y directions. Scaling -- by a negative factoralso reflects across that axis. scaled :: HasCallStack => Double -> Double -> Picture -> Picture -- | A picture scaled uniformly in all directions by this scale factor. -- Dilating by a negative factor also reflects across the origin. dilated :: HasCallStack => Double -> Picture -> Picture -- | A picture rotated by this angle about the origin. -- -- Angles are in radians. rotated :: HasCallStack => Double -> Picture -> Picture pictures :: HasCallStack => [Picture] -> Picture -- | An associative operation. (<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | Binary composition of pictures. (&) :: HasCallStack => 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 -- | A point in two dimensions. A point is written with the x coordinate -- first, and the y coordinate second. For example, (3, -2) is the point -- with x coordinate 3 a y coordinate -2. type Point = (Double, Double) -- | Moves a given point by given x and y offsets -- --
--   >>> translatedPoint 1 2 (10, 10)
--   (11.0, 12.0)
--   
--   >>> translatedPoint (-1) (-2) (0, 0)
--   (-1.0, -2.0)
--   
translatedPoint :: Double -> Double -> Point -> Point -- | Rotates a given point by given angle, in radians -- --
--   >>> rotatedPoint 45 (10, 0)
--   (7.071, 7.071)
--   
rotatedPoint :: Double -> Point -> Point -- | Scales a given point by given x and y scaling factor. Scaling by a -- negative factor also reflects across that axis. -- --
--   >>> scaledPoint 2 3 (10, 10)
--   (20, 30)
--   
scaledPoint :: Double -> Double -> Point -> Point -- | Dilates a given point by given uniform scaling factor. Dilating by a -- negative factor also reflects across the origin. -- --
--   >>> dilatedPoint 2 (10, 10)
--   (20, 20)
--   
dilatedPoint :: Double -> Point -> Point -- | A two-dimensional vector type Vector = (Double, Double) -- | The length of the given vector. -- --
--   >>> vectorLength (10, 10)
--   14.14
--   
vectorLength :: Vector -> Double -- | The counter-clockwise angle, in radians, that a given vector make with -- the X-axis -- --
--   >>> vectorDirection (1,0)
--   0.0
--   
--   >>> vectorDirection (1,1)
--   0.7853981633974483
--   
--   >>> vectorDirection (0,1)
--   1.5707963267948966
--   
vectorDirection :: Vector -> Double -- | The sum of two vectors vectorSum :: Vector -> Vector -> Vector -- | The difference of two vectors vectorDifference :: Vector -> Vector -> Vector -- | Scales a given vector by a given scalar multiplier. -- --
--   >>> scaledPoint 2 (10, 10)
--   (20, 20)
--   
scaledVector :: Double -> Vector -> Vector -- | Rotates a given vector by a given angle in radians -- --
--   >>> rotatedVector pi (1.0, 0.0)
--   (-1.0, 1.2246467991473532e-16)
--   
--   >>> rotatedVector (pi / 2) (1.0, 0.0)
--   (6.123233995736766e-17, 1.0)
--   
rotatedVector :: Double -> Vector -> Vector -- | The dot product of two vectors dotProduct :: Vector -> Vector -> Double data Color RGBA :: !Double -> !Double -> !Double -> !Double -> Color type Colour = Color pattern RGB :: Double -> Double -> Double -> Color pattern HSL :: Double -> Double -> Double -> Color black :: Color white :: Color red :: Color green :: Color blue :: Color yellow :: Color orange :: Color brown :: Color pink :: Color purple :: Color gray :: Color grey :: Color mixed :: [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 module CodeWorld -- | Draws a Picture. This is the simplest CodeWorld entry point. -- -- Example: a program which draws a circle of radius 1 in the middle of -- canvas -- --
--   main = drawingOf $ circle 1
--   
drawingOf :: Picture -> IO () -- | Shows an animation, with a picture for each time given by the -- parameter. -- -- Example: a program showing a square which rotates once every two -- seconds -- --
--   main = animationOf rotatingSquare
--   
--   rotatingSquare :: Double -> Picture
--   rotatingSquare seconds = rotated angle square
--     where
--       square = rectangle 2 2
--       angle = pi * seconds
--   
animationOf :: (Double -> Picture) -> IO () -- | Runs an interactive CodeWorld program that responds to Events. -- Activities can interact with the user, change over time, and remember -- information about the past. -- -- Example: a program which draws a circle and changes its radius when -- user presses Up or Down keys on her keyboard -- --
--    {-# LANGUAGE OverloadedStrings #-}
--   import CodeWorld
--   
--   main = activityOf initialRadius updateRadius circle
--      where
--        initialRadius = 1
--   
--        updateRadius event radius =
--          case event of
--            KeyPress Up   -> radius + 1
--            KeyPress Down -> radius - 1
--            _               -> radius
--   
activityOf :: world -> (Event -> world -> world) -> (world -> Picture) -> IO () -- | A version of activityOf which runs an interactive CodeWorld -- program in debugging mode. In this mode, the program gets controls to -- pause and manipulate time, and even go back in time to look at past -- states. debugActivityOf :: world -> (Event -> world -> world) -> (world -> Picture) -> IO () -- | Runs an interactive multi-user CodeWorld program that is joined by -- several participants over the internet. -- -- Example: a skeleton of a game for two players -- --
--   {-# LANGUAGE StaticPointers, OverloadedStrings #-}
--   import CodeWorld
--   
--   main = groupActivityOf 2 init step view
--     where
--       init = static (\gen -> {- initialize state of the game world, possibly using random number generator -})
--       step = static (\playerNumber event world -> {- modify world based on event occuring for given player -})
--       view = static (\playerNumber world -> {- generate a picture that will be shown to given player in the given state of the world-})
--   
groupActivityOf :: Int -> StaticPtr (StdGen -> world) -> StaticPtr (Int -> Event -> world -> world) -> StaticPtr (Int -> world -> Picture) -> IO () -- | A version of groupActivityOf that avoids static pointers, and -- does not check for consistency. unsafeGroupActivityOf :: Int -> (StdGen -> world) -> (Int -> Event -> world -> world) -> (Int -> world -> Picture) -> IO () -- | Shows a simulation, which is essentially a continuous-time dynamical -- system described by an initial value and step function. -- | Warning: Please use activityOf instead of simulationOf.simulationOf -- may be removed July 2020. simulationOf :: world -> (Double -> world -> world) -> (world -> Picture) -> IO () -- | Warning: Please use debugActivityOf instead of -- debugSimulationOf.debugSimulationOf may be removed July 2020. debugSimulationOf :: 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. -- | Warning: Please use activityOf instead of -- interactionOf.interactionOf may be removed July 2020. interactionOf :: world -> (Double -> world -> world) -> (Event -> world -> world) -> (world -> Picture) -> IO () -- | Warning: Please use debugActivityOf instead of -- debugInteractionOf.debugInteractionOf may be removed July 2020. debugInteractionOf :: world -> (Double -> world -> world) -> (Event -> world -> world) -> (world -> Picture) -> IO () -- | Runs an interactive multi-user CodeWorld program, involving multiple -- participants over the internet. -- | Warning: Please use groupActivityOf instead of -- collaborationOf.collaborationOf may be removed July 2020. 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. -- | Warning: Please use unsafeGroupActivityOf instead of -- unsafeCollaborationOf.unsafeCollaborationOf may be removed July -- 2020. unsafeCollaborationOf :: Int -> (StdGen -> world) -> (Double -> world -> world) -> (Int -> Event -> world -> world) -> (Int -> world -> Picture) -> IO () -- | A design, diagram, or drawing that can be displayed and seen. In -- technical terms, a picture is an assignment of a color to every point -- of the coordinate plane. CodeWorld contains functions to create -- pictures from simple geometry primitives, to transform existing -- pictures, and to combine simpler pictures into more complex -- compositions. -- -- Ultimately, a picture can be drawn on the screen using one of the -- CodeWorld entry points such as drawingOf. data Picture data TextStyle -- | Plain letters with no style Plain :: TextStyle -- | Heavy, thick lettering used for emphasis Bold :: TextStyle -- | Slanted script-like lettering used for emphasis Italic :: TextStyle data Font SansSerif :: Font Serif :: Font Monospace :: Font Handwriting :: Font Fancy :: Font NamedFont :: !Text -> Font -- | A blank picture blank :: HasCallStack => 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 may be removed -- July 2020. 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 -- may be removed July 2020. 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 thick smooth closed curve with this line width, passing through -- these points. thickClosedCurve :: HasCallStack => Double -> [Point] -> Picture -- | A solid smooth closed curve passing through these points. solidClosedCurve :: 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 rendering of text characters. -- | Warning: Please used lettering instead of text.text may be removed -- July 2020. text :: HasCallStack => Text -> Picture -- | A rendering of text characters. lettering :: HasCallStack => Text -> Picture -- | A rendering of text characters, with a specific choice of font and -- style. -- | Warning: Please used styledLettering instead of -- styledText.styledText may be removed July 2020. styledText :: HasCallStack => TextStyle -> Font -> Text -> Picture -- | A rendering of text characters onto a Picture, with a specific choice -- of font and style. styledLettering :: 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 in the x and y directions. Scaling -- by a negative factoralso reflects across that axis. scaled :: HasCallStack => Double -> Double -> Picture -> Picture -- | A picture scaled uniformly in all directions by this scale factor. -- Dilating by a negative factor also reflects across the origin. dilated :: HasCallStack => Double -> Picture -> Picture -- | A picture rotated by this angle about the origin. -- -- Angles are in radians. rotated :: HasCallStack => Double -> Picture -> Picture -- | A picture reflected across a line through the origin at this angle, in -- radians. For example, an angle of 0 reflects the picture vertically -- across the x axis, while an angle of pi / 2 reflects the -- picture horizontally across the y axis. reflected :: HasCallStack => Double -> Picture -> Picture -- | A picture clipped to a rectangle around the origin with this width and -- height. clipped :: HasCallStack => Double -> Double -> Picture -> Picture pictures :: HasCallStack => [Picture] -> Picture -- | An associative operation. (<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | Binary composition of pictures. (&) :: HasCallStack => 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 -- | A point in two dimensions. A point is written with the x coordinate -- first, and the y coordinate second. For example, (3, -2) is the point -- with x coordinate 3 a y coordinate -2. type Point = (Double, Double) -- | Moves a given point by given x and y offsets -- --
--   >>> translatedPoint 1 2 (10, 10)
--   (11.0, 12.0)
--   
--   >>> translatedPoint (-1) (-2) (0, 0)
--   (-1.0, -2.0)
--   
translatedPoint :: Double -> Double -> Point -> Point -- | Rotates a given point by given angle, in radians -- --
--   >>> rotatedPoint 45 (10, 0)
--   (7.071, 7.071)
--   
rotatedPoint :: Double -> Point -> Point -- | Reflects a given point across a line through the origin at this angle, -- in radians. For example, an angle of 0 reflects the point vertically -- across the x axis, while an angle of pi / 2 reflects the -- point horizontally across the y axis. reflectedPoint :: Double -> Point -> Point -- | Scales a given point by given x and y scaling factor. Scaling by a -- negative factor also reflects across that axis. -- --
--   >>> scaledPoint 2 3 (10, 10)
--   (20, 30)
--   
scaledPoint :: Double -> Double -> Point -> Point -- | Dilates a given point by given uniform scaling factor. Dilating by a -- negative factor also reflects across the origin. -- --
--   >>> dilatedPoint 2 (10, 10)
--   (20, 20)
--   
dilatedPoint :: Double -> Point -> Point -- | A two-dimensional vector type Vector = (Double, Double) -- | The length of the given vector. -- --
--   >>> vectorLength (10, 10)
--   14.14
--   
vectorLength :: Vector -> Double -- | The counter-clockwise angle, in radians, that a given vector make with -- the X-axis -- --
--   >>> vectorDirection (1,0)
--   0.0
--   
--   >>> vectorDirection (1,1)
--   0.7853981633974483
--   
--   >>> vectorDirection (0,1)
--   1.5707963267948966
--   
vectorDirection :: Vector -> Double -- | The sum of two vectors vectorSum :: Vector -> Vector -> Vector -- | The difference of two vectors vectorDifference :: Vector -> Vector -> Vector -- | Scales a given vector by a given scalar multiplier. -- --
--   >>> scaledPoint 2 (10, 10)
--   (20, 20)
--   
scaledVector :: Double -> Vector -> Vector -- | Rotates a given vector by a given angle in radians -- --
--   >>> rotatedVector pi (1.0, 0.0)
--   (-1.0, 1.2246467991473532e-16)
--   
--   >>> rotatedVector (pi / 2) (1.0, 0.0)
--   (6.123233995736766e-17, 1.0)
--   
rotatedVector :: Double -> Vector -> Vector -- | The dot product of two vectors dotProduct :: Vector -> Vector -> Double data Color RGBA :: !Double -> !Double -> !Double -> !Double -> Color type Colour = Color pattern RGB :: Double -> Double -> Double -> Color pattern HSL :: Double -> Double -> Double -> Color black :: Color white :: Color red :: Color green :: Color blue :: Color -- | Warning: Please use HSL(pi, 0.75, 0.5) instead of cyan.The variable -- cyan may be removed July 2020. cyan :: Color -- | Warning: Please use HSL(5 * pi / 3, 0.75, 0.5) instead of -- magenta.The variable magenta may be removed July 2020. magenta :: Color yellow :: Color -- | Warning: Please use HSL(5 * pi / 6, 0.75, 0.5) instead of -- aquamarine.The variable aquamarine may be removed July 2020. aquamarine :: Color orange :: Color -- | Warning: Please use HSL(7 * pi / 6, 0.75, 0.5) instead of azure.The -- variable azure may be removed July 2020. azure :: Color -- | Warning: Please use purple instead of violet.The variable violet -- may be removed July 2020. violet :: Color -- | Warning: Please use HSL(pi / 2, 0.75, 0.5) instead of -- chartreuse.The variable chartreuse may be removed July 2020. chartreuse :: Color -- | Warning: Please use HSL(11 * pi / 6, 0.75, 0.5) instead of rose.The -- variable rose may be removed July 2020. rose :: Color brown :: Color pink :: Color purple :: Color gray :: Color grey :: Color mixed :: [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 -- | An event initiated by the user. -- -- Values of this type represent events that the user triggers when using -- an interactive program. -- -- 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 PointerPress :: !Point -> Event PointerRelease :: !Point -> Event PointerMovement :: !Point -> Event TextEntry :: !Text -> Event TimePassing :: !Double -> Event -- | 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 sets appropriate buffering to use the -- CodeWorld console. trace :: Text -> a -> a -- | Warning: This is an experimental API. It can change at any -- time. module CodeWorld.Parameter -- | The source for a parameter that can be adjusted in a parametric -- drawing. Parameters can get their values from sliders, buttons, -- counters, timers, etc. data Parameter -- | A drawing that depends on parameters. The first argument is a list of -- parameters. The second is a picture, which depends on the values of -- those parameters. Each number used to retrieve the picture is the -- value of the corresponding parameter in the first list. parametricDrawingOf :: [Parameter] -> ([Double] -> Picture) -> IO () -- | A Parameter that can be adjusted continuously between 0 and 1. slider :: Text -> Parameter -- | A Parameter that can be toggled between 0 (off) and 1 (on). toggle :: Text -> Parameter -- | A Parameter that counts how many times it has been clicked. counter :: Text -> Parameter -- | A Parameter with a constant value, and no way to change it. constant :: Text -> Double -> Parameter -- | A Parameter that has a randomly chosen value. It offers a -- button to regenerate its value. random :: Text -> Parameter -- | A Parameter that changes over time. It can be paused or reset. timer :: Text -> Parameter -- | A Parameter that tracks the current hour, in local time. The -- hour is on a scale from 0 (meaning midnight) to 23 (meaning 11:00 pm). currentHour :: Parameter -- | A Parameter that tracks the current minute, in local time. It -- ranges from 0 to 59. currentMinute :: Parameter -- | A Parameter that tracks the current second, in local time. It -- ranges from 0.0 up to (but not including) 60.0. This includes -- fractions of a second. If that's not what you want, you can use -- withConversion to truncate the number. currentSecond :: Parameter -- | Adjusts the output of a parameter by passing it through a conversion -- function. Built-in parameters usually range from 0 to 1, and -- conversions can be used to rescale the output to a different range. converted :: (Double -> Double) -> Parameter -> Parameter -- | Changes the name of an existing parameter. renamed :: Text -> Parameter -> Parameter -- | Warning: This is an experimental API. It can change at any -- time. module CodeWorld.App2 data Application :: * -> * defaultApplication :: state -> Application state withTimeStep :: (Double -> state -> state) -> Application state -> Application state withEventHandler :: (Event -> state -> state) -> Application state -> Application state withPicture :: (state -> Picture) -> Application state -> Application state withMultiEventHandler :: (Int -> Event -> state -> state) -> Application state -> Application state withMultiPicture :: (Int -> state -> Picture) -> Application state -> Application state subapplication :: (a -> b) -> (b -> a -> a) -> Application b -> (b -> a) -> Application a applicationOf :: Application world -> IO () -- | Warning: This is an experimental API. It can change at any -- time. module CodeWorld.App data Rule :: * -> * timeRule :: (Double -> state -> state) -> Rule state eventRule :: (Event -> state -> state) -> Rule state pictureRule :: (state -> Picture) -> Rule state multiEventRule :: (Int -> Event -> state -> state) -> Rule state multiPictureRule :: (Int -> state -> Picture) -> Rule state subrule :: (a -> b) -> (b -> a -> a) -> Rule b -> Rule a rules :: [Rule state] -> Rule state applicationOf :: world -> [Rule world] -> IO () unsafeMultiApplicationOf :: Int -> (StdGen -> state) -> [Rule state] -> IO ()