Safe Haskell | None |
---|---|
Language | Haskell2010 |
CodeWorld
Description
Module exporting the same interface as provided in the CodeWorld editor.
Synopsis
- data Picture
- (&) :: Picture -> Picture -> Picture
- rectangle :: Double -> Double -> Picture
- solidRectangle :: Double -> Double -> Picture
- thickRectangle :: Double -> Double -> Double -> Picture
- circle :: Double -> Picture
- solidCircle :: Double -> Picture
- arc :: Double -> Double -> Double -> Picture
- sector :: Double -> Double -> Double -> Picture
- thickArc :: Double -> Double -> Double -> Double -> Picture
- curve :: [Point] -> Picture
- thickCurve :: Double -> [Point] -> Picture
- closedCurve :: [Point] -> Picture
- thickClosedCurve :: Double -> [Point] -> Picture
- solidClosedCurve :: [Point] -> Picture
- polyline :: [Point] -> Picture
- thickPolyline :: Double -> [Point] -> Picture
- polygon :: [Point] -> Picture
- solidPolygon :: [Point] -> Picture
- thickPolygon :: Double -> [Point] -> Picture
- lettering :: Text -> Picture
- styledLettering :: TextStyle -> Font -> Text -> Picture
- thickCircle :: Double -> Double -> Picture
- translated :: Double -> Double -> Picture -> Picture
- colored :: Color -> Picture -> Picture
- coloured :: Color -> Picture -> Picture
- dilated :: Double -> Picture -> Picture
- scaled :: Double -> Double -> Picture -> Picture
- rotated :: Double -> Picture -> Picture
- reflected :: Double -> Picture -> Picture
- clipped :: Double -> Double -> Picture -> Picture
- pictures :: [Picture] -> Picture
- coordinatePlane :: Picture
- codeWorldLogo :: Picture
- blank :: Picture
- data Color
- type Colour = Color
- red :: Color
- green :: Color
- yellow :: Color
- black :: Color
- white :: Color
- blue :: Color
- orange :: Color
- brown :: Color
- pink :: Color
- purple :: Color
- grey :: Color
- gray :: 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
- assortedColors :: [Color]
- hue :: Color -> Double
- saturation :: Color -> Double
- luminosity :: Color -> Double
- alpha :: Color -> Double
- type Point = (Double, Double)
- type Vector = (Double, Double)
- translatedPoint :: Double -> Double -> Point -> Point
- rotatedPoint :: Double -> Point -> Point
- reflectedPoint :: Double -> Point -> Point
- scaledPoint :: Double -> Double -> Point -> Point
- dilatedPoint :: Double -> Point -> Point
- vectorLength :: Vector -> Double
- vectorDirection :: Vector -> Double
- vectorSum :: Vector -> Vector -> Vector
- vectorDifference :: Vector -> Vector -> Vector
- scaledVector :: Double -> Double -> Vector -> Vector
- rotatedVector :: Double -> Vector -> Vector
- dotProduct :: Vector -> Vector -> Double
- data Font
- data TextStyle
- drawingOf :: Picture -> IO ()
- animationOf :: (Double -> Picture) -> IO ()
- trace :: Text -> a -> a
CodeWorld API
The CodeWorld Picture
type and corresponding API for composing images.
Student facing, basic picture type. A value of this type can be build using the CodeWorld API.
CodeWorld.Test also exports pattern synonyms for all contained constructors. This allows for easier pattern matching in generic traversals.
Instances
Data Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Picture -> c Picture # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Picture # toConstr :: Picture -> Constr # dataTypeOf :: Picture -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Picture) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Picture) # gmapT :: (forall b. Data b => b -> b) -> Picture -> Picture # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Picture -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Picture -> r # gmapQ :: (forall d. Data d => d -> u) -> Picture -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Picture -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Picture -> m Picture # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Picture -> m Picture # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Picture -> m Picture # | |||||
Generic Picture Source # | |||||
Show Picture Source # | |||||
MuRef Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture Associated Types
| |||||
NFData Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
Eq Picture Source # | |||||
Ord Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
type Rep Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
type DeRef Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture type DeRef Picture |
(&) :: Picture -> Picture -> Picture Source #
Compose two Picture
s.
The left argument will drawn on top of the right argument if they overlap.
rectangle :: Double -> Double -> Picture Source #
Draw a hollow, thin rectangle with this length and height.
solidRectangle :: Double -> Double -> Picture Source #
Draw a filled in rectangle with this length and height.
thickRectangle :: Double -> Double -> Double -> Picture Source #
Draw a hollow rectangle with this line width, length and height. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).
solidCircle :: Double -> Picture Source #
Draw a filled in circle with this radius.
arc :: Double -> Double -> Double -> Picture Source #
Draw a thin, hollow circle segment with these start and end angles and radius.
sector :: Double -> Double -> Double -> Picture Source #
Draw a filled in circle segment with these start and end angles and radius.
This would be solidArc
following the usual naming scheme.
thickArc :: Double -> Double -> Double -> Double -> Picture Source #
Draw a hollow circle segment with this line width, these start and end angles and radius. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).
curve :: [Point] -> Picture Source #
Draw a thin curve passing through the provided points via a number of Bézier splices.
thickCurve :: Double -> [Point] -> Picture Source #
Draw a curve with this line width passing through the provided points via a number of Bézier splices. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).
closedCurve :: [Point] -> Picture Source #
Same as curve
but adds another splice between the start and end points to close the shape.
thickClosedCurve :: Double -> [Point] -> Picture Source #
Same as thickCurve
but adds another splice between the start and end points to close the shape.
solidClosedCurve :: [Point] -> Picture Source #
Draw a curve passing through the provided points via a number of Bézier splices. Adds another splice between the start and end points to close the shape and completely fills the enclosed area.
polyline :: [Point] -> Picture Source #
Draw a sequence of thin line segments passing through the provided points.
thickPolyline :: Double -> [Point] -> Picture Source #
Draw a sequence of line segments with this line width passing through the provided points. Specifying a negative line width causes a runtime error (mirrors behaviour in CodeWorld editor).
polygon :: [Point] -> Picture Source #
Same as polyline
but adds another segment between the start and end points to close the shape.
solidPolygon :: [Point] -> Picture Source #
Draw a sequence of line segments with this line width passing through the provided points and completely fill the enclosed area.
thickPolygon :: Double -> [Point] -> Picture Source #
Same as thickPolyline
but adds another segment between the start and end points to close the shape.
thickCircle :: Double -> Double -> Picture Source #
Draw a hollow circle with this line width and radius. Specifying a negative line width or a line width greater than the circles diameter causes a runtime error (mirrors behaviour in CodeWorld editor).
dilated :: Double -> Picture -> Picture Source #
Scale the image in both directions using the same modifier.
scaled :: Double -> Double -> Picture -> Picture Source #
Scale the image in x and y-directions using these modifiers.
rotated :: Double -> Picture -> Picture Source #
Rotate the image around the origin using this angle in radians.
reflected :: Double -> Picture -> Picture Source #
Reflect the image across a line through the origin with this angle to the x-axis.
clipped :: Double -> Double -> Picture -> Picture Source #
Clip the image in a rectangle with this length and height.
coordinatePlane :: Picture Source #
A static image of a coordinate plane extending 5 units in all directions.
codeWorldLogo :: Picture Source #
A static image of the CodeWorld logo.
Colours
Color type mirroring CodeWorld's equivalent type. The exposed constructors allow for setting colors directly via numerical values.
Constructors
RGB Double Double Double | Values for red, green, blue given as a percentage from 0 to 1 |
HSL Double Double Double | Values for hue, saturation and luminosity |
RGBA Double Double Double Double | RGB with an additional transparency percentage |
Instances
lighter :: Double -> Color -> Color Source #
Increase argument's luminosity by a user defined amount.
brighter :: Double -> Color -> Color Source #
Increase argument's saturation by a user defined amount.
translucent :: Color -> Color Source #
Slightly increase argument's transparency.
assortedColors :: [Color] Source #
An infinite list of different colours.
saturation :: Color -> Double Source #
Returns the saturation of the argument according to the HSL model.
luminosity :: Color -> Double Source #
Returns the luminosity of the argument according to the HSL model.
Math Utility
rotatedPoint :: Double -> Point -> Point Source #
Rotates a point around the origin by the given angle in radians.
reflectedPoint :: Double -> Point -> Point Source #
Reflects a point across a line through the origin at this angle from the X-axis.
scaledPoint :: Double -> Double -> Point -> Point Source #
Scales a point by given X and Y scaling factor. Scaling by a negative factor also reflects across that axis.
dilatedPoint :: Double -> Point -> Point Source #
Dilates a point by given uniform scaling factor. Dilating by a negative factor also reflects across the origin.
vectorLength :: Vector -> Double Source #
The length of a vector.
vectorDirection :: Vector -> Double Source #
The counter-clockwise angle of a vector from the X-axis.
scaledVector :: Double -> Double -> Vector -> Vector Source #
Scales a vector by the given scalar multiplier.
Text Rendering Modifiers
Text font type used for stylized message rendering.
Instances
Data Font Source # | |||||
Defined in CodeWorld.Tasks.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Font -> c Font # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Font # dataTypeOf :: Font -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Font) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Font) # gmapT :: (forall b. Data b => b -> b) -> Font -> Font # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Font -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Font -> r # gmapQ :: (forall d. Data d => d -> u) -> Font -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Font -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Font -> m Font # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Font -> m Font # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Font -> m Font # | |||||
Generic Font Source # | |||||
Defined in CodeWorld.Tasks.Types Associated Types
| |||||
Show Font Source # | |||||
NFData Font Source # | |||||
Defined in CodeWorld.Tasks.Types | |||||
Eq Font Source # | |||||
Ord Font Source # | |||||
type Rep Font Source # | |||||
Defined in CodeWorld.Tasks.Types type Rep Font = D1 ('MetaData "Font" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-ALYWrqBU5SkHyps14Jeeld" 'False) ((C1 ('MetaCons "SansSerif" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Serif" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Monospace" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Handwriting" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Fancy" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NamedFont" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))) |
Font modifier type used for stylized message rendering.
Instances
Data TextStyle Source # | |||||
Defined in CodeWorld.Tasks.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TextStyle -> c TextStyle # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TextStyle # toConstr :: TextStyle -> Constr # dataTypeOf :: TextStyle -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TextStyle) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TextStyle) # gmapT :: (forall b. Data b => b -> b) -> TextStyle -> TextStyle # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TextStyle -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TextStyle -> r # gmapQ :: (forall d. Data d => d -> u) -> TextStyle -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TextStyle -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TextStyle -> m TextStyle # | |||||
Generic TextStyle Source # | |||||
Defined in CodeWorld.Tasks.Types Associated Types
| |||||
Show TextStyle Source # | |||||
NFData TextStyle Source # | |||||
Defined in CodeWorld.Tasks.Types | |||||
Eq TextStyle Source # | |||||
Ord TextStyle Source # | |||||
type Rep TextStyle Source # | |||||
Defined in CodeWorld.Tasks.Types type Rep TextStyle = D1 ('MetaData "TextStyle" "CodeWorld.Tasks.Types" "codeworld-tasks-0.1.0.0-ALYWrqBU5SkHyps14Jeeld" 'False) (C1 ('MetaCons "Plain" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bold" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Italic" 'PrefixI 'False) (U1 :: Type -> Type))) |
CodeWorld IO Interface
Entry points for rendering.
Defining the main
function in terms of one of these
would draw the provided image to screen.
All of these are dummy functions (no-op IO actions) as this library does not implement the actual rendering process.