| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
CodeWorld.Test
Description
Module exporting all functionality needed for running tests on student submissions.
Synopsis
- data AbstractPicture
- someCircle :: AbstractPicture
- someSolidCircle :: AbstractPicture
- someSquare :: AbstractPicture
- someRectangle :: AbstractPicture
- someTallRectangle :: AbstractPicture
- someWideRectangle :: AbstractPicture
- someSolidSquare :: AbstractPicture
- someSolidRectangle :: AbstractPicture
- someTallSolidRectangle :: AbstractPicture
- someWideSolidRectangle :: AbstractPicture
- someCurve :: Int -> AbstractPicture
- someSolidCurve :: Int -> AbstractPicture
- withColor :: Color -> AbstractPicture -> AbstractPicture
- someColor :: AbstractPicture -> AbstractPicture
- rotatedHalf :: AbstractPicture -> AbstractPicture
- rotatedQuarter :: AbstractPicture -> AbstractPicture
- rotatedThreeQuarters :: AbstractPicture -> AbstractPicture
- rotatedUpToFull :: AbstractPicture -> AbstractPicture
- larger :: AbstractPicture -> AbstractPicture
- largerX :: AbstractPicture -> AbstractPicture
- largerY :: AbstractPicture -> AbstractPicture
- smaller :: AbstractPicture -> AbstractPicture
- smallerX :: AbstractPicture -> AbstractPicture
- smallerY :: AbstractPicture -> AbstractPicture
- (.&.) :: AbstractPicture -> AbstractPicture -> AbstractPicture
- contains :: AbstractPicture -> AbstractPicture -> Bool
- count :: AbstractPicture -> AbstractPicture -> Int
- getColor :: AbstractPicture -> Maybe AbsColor
- getRotation :: AbstractPicture -> Maybe Angle
- getExactRotation :: AbstractPicture -> Double
- getScalingFactors :: AbstractPicture -> (Factor, Factor)
- getExactScalingFactors :: AbstractPicture -> (Double, Double)
- getTranslation :: AbstractPicture -> (Position, Position)
- getExactTranslation :: AbstractPicture -> (Double, Double)
- getReflectionAngle :: AbstractPicture -> Maybe Angle
- getExactReflectionAngle :: AbstractPicture -> Double
- getCircleRadius :: AbstractPicture -> Maybe Size
- getExactCircleRadius :: AbstractPicture -> Maybe Double
- getRectangleLengths :: AbstractPicture -> Maybe (Size, Size)
- getExactRectangleLengths :: AbstractPicture -> Maybe (Double, Double)
- getExactPointList :: AbstractPicture -> [Point]
- data Size
- data ShapeKind
- data Angle
- data Factor
- data Position
- data AbsPoint
- data AbsColor
- isSameColor :: AbsColor -> AbsColor -> Bool
- data RelativePicSpec
- type SpatialQuery = [RelativePicSpec] -> Bool
- isSouthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isNorthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isSouthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isSouthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isNorthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isNorthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isBelow :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isAbove :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isLeftOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- isRightOf :: AbstractPicture -> AbstractPicture -> SpatialQuery
- atSamePosition :: AbstractPicture -> AbstractPicture -> SpatialQuery
- data Components
- type StaticImage = (Picture, Components)
- type Animation = Double -> StaticImage
- containsElem :: MonadReader StaticImage m => AbstractPicture -> m Bool
- containsElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool
- containsExactElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool
- thisOften :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool
- atLeast :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool
- atMost :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool
- inRangeOf :: MonadReader StaticImage m => AbstractPicture -> (Int, Int) -> m Bool
- hasRelation :: MonadReader StaticImage m => SpatialQuery -> m Bool
- (<||>) :: MonadReader env m => m Bool -> m Bool -> m Bool
- (<&&>) :: MonadReader env m => m Bool -> m Bool -> m Bool
- (<^^>) :: MonadReader env m => m Bool -> m Bool -> m Bool
- option :: MonadReader env m => m Bool -> m Bool -> m Bool
- options :: MonadReader env m => [m Bool] -> m Bool
- ifThen :: MonadReader env m => m Bool -> m Bool -> m Bool
- oneOf :: MonadReader env m => (a -> m Bool) -> [a] -> m Bool
- rawImage :: MonadReader StaticImage m => m Picture
- normalizedImage :: MonadReader StaticImage m => m Picture
- findAll :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture]
- findAllThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a]
- findAllTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture]
- findAllTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a]
- findFirst :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture)
- findFirstThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a)
- findFirstTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture)
- findFirstTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a)
- mapAnimation :: MonadReader Animation m => (StaticImage -> a) -> m (Double -> a)
- atTime :: forall (m :: Type -> Type) a. Double -> ReaderT StaticImage m a -> ReaderT Animation m a
- rawImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture]
- normalizedImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture]
- anyAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool
- allAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool
- allAtWithTime :: [Double] -> (Double -> Reader StaticImage Bool) -> Reader Animation Bool
- noneAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool
- queryAt :: forall (m :: Type -> Type) a. Applicative m => [Double] -> ReaderT StaticImage m a -> ReaderT Animation m [a]
- complain :: String -> Reader env Bool -> ReaderT env (Except String) ()
- testPicture :: Picture -> ReaderT StaticImage (Except String) () -> String
- testAnimation :: (Double -> Picture) -> ReaderT Animation (Except String) () -> String
- data Picture where
- pattern Rectangle :: Double -> Double -> Picture
- pattern ThickRectangle :: Double -> Double -> Double -> Picture
- pattern SolidRectangle :: Double -> Double -> Picture
- pattern Circle :: Double -> Picture
- pattern ThickCircle :: Double -> Double -> Picture
- pattern SolidCircle :: Double -> Picture
- pattern Polygon :: [Point] -> Picture
- pattern SolidPolygon :: [Point] -> Picture
- pattern ThickPolygon :: Double -> [Point] -> Picture
- pattern Polyline :: [Point] -> Picture
- pattern ThickPolyline :: Double -> [Point] -> Picture
- pattern Sector :: Double -> Double -> Double -> Picture
- pattern Arc :: Double -> Double -> Double -> Picture
- pattern ThickArc :: Double -> Double -> Double -> Double -> Picture
- pattern Curve :: [Point] -> Picture
- pattern ThickCurve :: Double -> [Point] -> Picture
- pattern ClosedCurve :: [Point] -> Picture
- pattern SolidClosedCurve :: [Point] -> Picture
- pattern ThickClosedCurve :: Double -> [Point] -> Picture
- pattern Lettering :: Text -> Picture
- pattern StyledLettering :: TextStyle -> Font -> Text -> Picture
- pattern Color :: Color -> Picture -> Picture
- pattern Translate :: Double -> Double -> Picture -> Picture
- pattern Scale :: Double -> Double -> Picture -> Picture
- pattern Dilate :: Double -> Picture -> Picture
- pattern Rotate :: Double -> Picture -> Picture
- pattern Reflect :: Double -> Picture -> Picture
- pattern Clip :: Double -> Double -> Picture -> Picture
- pattern Pictures :: [Picture] -> Picture
- pattern And :: Picture -> Picture -> Picture
- pattern CoordinatePlane :: Picture
- pattern Logo :: Picture
- pattern Blank :: Picture
- hasInnerPicture :: Picture -> Bool
- innerPicture :: Picture -> Picture
- isIn :: Picture -> (Point, Point) -> Bool
- normalize :: Picture -> Picture
- normalizeNoOrder :: Picture -> Picture
- normalizeAndAbstract :: Picture -> AbstractPicture
- toConcretePicture :: AbstractPicture -> Picture
- wasTranslatedBy :: [Point] -> [Point] -> Maybe Point
- wasScaledBy :: [Point] -> [Point] -> Maybe (Maybe Double, Maybe Double)
- wasRotatedBy :: [Point] -> [Point] -> Maybe Double
- irregularSamples :: [Double]
- samplesUntil :: Double -> Double -> [Double]
- testCSE :: Picture -> IO (Maybe String)
- rectangle :: Double -> Double -> Picture
- thickRectangle :: Double -> Double -> Double -> Picture
- solidRectangle :: Double -> Double -> Picture
- circle :: Double -> Picture
- thickCircle :: Double -> 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
- thickPolygon :: Double -> [Point] -> Picture
- solidPolygon :: [Point] -> Picture
- lettering :: Text -> Picture
- styledLettering :: TextStyle -> Font -> Text -> Picture
- colored :: Color -> Picture -> Picture
- coloured :: Color -> Picture -> Picture
- translated :: Double -> Double -> Picture -> Picture
- scaled :: Double -> Double -> Picture -> Picture
- dilated :: Double -> Picture -> Picture
- rotated :: Double -> Picture -> Picture
- reflected :: Double -> Picture -> Picture
- clipped :: Double -> Double -> Picture -> Picture
- pictures :: [Picture] -> Picture
- (&) :: Picture -> Picture -> Picture
- coordinatePlane :: Picture
- codeWorldLogo :: Picture
- blank :: Picture
- 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
- data Font
- data TextStyle
- 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
Normalized Pictures
Data Type
data AbstractPicture Source #
A more abstract syntax tree representing images. Comparisons between values of this type are intentionally fuzzy: Concrete number or point values are abstracted into coarser categories. Notably, those values are not lost and can be retrieved if desired.
The constructors of this type are not exposed. Values are built using the CodeWorld API.
Instances
Helpers for defining AbstractPictures
You'll want to compare something to or query for some abstract picture frequently in tests, e.g. ask if there's a *yellow circle* somewhere in the image (but the size of the circle is not important).
The following functions can be used to build such a generalized image directly, instead of creating a normal picture, then abstracting it.
someCircle :: AbstractPicture Source #
Draw an abstract, hollow circle.
someSolidCircle :: AbstractPicture Source #
Draw an abstract, filled in circle.
someSquare :: AbstractPicture Source #
Draw an abstract, hollow square.
someRectangle :: AbstractPicture Source #
Draw an abstract, hollow rectangle.
This is an alias for someSquare.
someTallRectangle :: AbstractPicture Source #
Draw an abstract, hollow rectangle that is taller than wide.
someWideRectangle :: AbstractPicture Source #
Draw an abstract, hollow rectangle that is wider than tall.
someSolidSquare :: AbstractPicture Source #
Draw an abstract, filled in square.
someSolidRectangle :: AbstractPicture Source #
Draw an abstract, filled in rectangle.
This is an alias for someSolidSquare.
someTallSolidRectangle :: AbstractPicture Source #
Draw an abstract, filled in rectangle that is taller than wide.
someWideSolidRectangle :: AbstractPicture Source #
Draw an abstract, filled in rectangle that is wider than tall.
someCurve :: Int -> AbstractPicture Source #
Draw an abstract, open curve with this many segments.
someSolidCurve :: Int -> AbstractPicture Source #
Draw an abstract, filled in and closed curve with this many segments.
withColor :: Color -> AbstractPicture -> AbstractPicture Source #
Provide an abstract shape with a specific color.
The color will be treated as equal to any color with *similar* HSL values.
(See isSameColor for more information)
someColor :: AbstractPicture -> AbstractPicture Source #
Provide an abstract shape with a wildcard color. The color will be treated as equal to any other color.
rotatedHalf :: AbstractPicture -> AbstractPicture Source #
Rotate an abstract shape by between a quarter and half turn.
rotatedQuarter :: AbstractPicture -> AbstractPicture Source #
Rotate an abstract shape by up to a quarter turn.
rotatedThreeQuarters :: AbstractPicture -> AbstractPicture Source #
Rotate an abstract shape by between a half and three quarters turn.
rotatedUpToFull :: AbstractPicture -> AbstractPicture Source #
Rotate an abstract shape by between a three quarters and up to a full turn. The full turn itself is excluded.
larger :: AbstractPicture -> AbstractPicture Source #
Enlarge an abstract shape. Both directions are scaled an equal amount.
largerX :: AbstractPicture -> AbstractPicture Source #
Enlarge an abstract shape in X-direction. The Y-direction is unchanged.
largerY :: AbstractPicture -> AbstractPicture Source #
Enlarge an abstract shape in Y-direction. The X-direction is unchanged.
smaller :: AbstractPicture -> AbstractPicture Source #
Shrink an abstract shape. Both directions are scaled an equal amount.
smallerX :: AbstractPicture -> AbstractPicture Source #
Shrink an abstract shape in X-direction. The Y-direction is unchanged.
smallerY :: AbstractPicture -> AbstractPicture Source #
Shrink an abstract shape in Y-direction. The X-direction is unchanged.
(.&.) :: AbstractPicture -> AbstractPicture -> AbstractPicture Source #
Compose two abstract pictures.
Queries on AbstractPictures
Functions for retrieving parameters of an AbstractPicture.
For each parameter there is an abstract and a concrete version.
The concrete version simply removes the abstract type wrapper and returns the contained value.
These are meant to be used on non-composite values only (no & or pictures),
meaning only one value is returned.
Use the functions in Queries on Components if retrieval of all parameters of a specific kind is desired.
contains :: AbstractPicture -> AbstractPicture -> Bool Source #
True if the first image contains the second image. This uses fuzzy comparison.
count :: AbstractPicture -> AbstractPicture -> Int Source #
Returns how often a subpicture appears in the image.
getColor :: AbstractPicture -> Maybe AbsColor Source #
Returns the AbsColor of the image.
Nothing if it is one of logo or coordinate plane.
Black if none.
getRotation :: AbstractPicture -> Maybe Angle Source #
Returns abstract rotation of the image if it has any.
getExactRotation :: AbstractPicture -> Double Source #
Returns actual rotation of the image if it has any.
getScalingFactors :: AbstractPicture -> (Factor, Factor) Source #
Returns the abstract scaling factors of the image. Neutral factors if none.
getExactScalingFactors :: AbstractPicture -> (Double, Double) Source #
Returns actual scaling factors of the image. (1,1) if none.
getTranslation :: AbstractPicture -> (Position, Position) Source #
Returns the abstract translation of the image. Neutral translation if none.
getExactTranslation :: AbstractPicture -> (Double, Double) Source #
Returns the actual translation of the image. (0,0) if none.
getReflectionAngle :: AbstractPicture -> Maybe Angle Source #
Returns abstract reflection of the image if it has any.
getExactReflectionAngle :: AbstractPicture -> Double Source #
Returns actual reflection of the image if it has any.
getCircleRadius :: AbstractPicture -> Maybe Size Source #
Returns abstract radius of the image if it actually a circle or circle segment.
getExactCircleRadius :: AbstractPicture -> Maybe Double Source #
Returns actual radius of the image if it actually a circle or circle segment.
getRectangleLengths :: AbstractPicture -> Maybe (Size, Size) Source #
Returns abstract side lengths of the image if it actually a rectangle.
getExactRectangleLengths :: AbstractPicture -> Maybe (Double, Double) Source #
Returns actual side lengths of the image if it actually a rectangle.
getExactPointList :: AbstractPicture -> [Point] Source #
Returns actual list of points in the image if it is a "free shape", [] otherwise.
Abstract Representations of CodeWorld Types
Abstract versions of data types used as parameters in CodeWorld's Picture type.
Retain the concrete value, unless stated otherwise, so it can be extracted if necessary.
Abstract representation of radii and side lengths. All values are considered equal.
Instances
| Data Size Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Size -> c Size # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Size # dataTypeOf :: Size -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Size) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Size) # gmapT :: (forall b. Data b => b -> b) -> Size -> Size # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Size -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Size -> r # gmapQ :: (forall d. Data d => d -> u) -> Size -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Size -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Size -> m Size # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Size -> m Size # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Size -> m Size # | |
| Show Size Source # | |
| Eq Size Source # | |
| Ord Size Source # | |
Abstract representation of line drawing and filling mode. Differentiates between the three common shapes: standard, thick, filled.
This does not retain the concrete value.
Instances
| Data ShapeKind Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ShapeKind -> c ShapeKind # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ShapeKind # toConstr :: ShapeKind -> Constr # dataTypeOf :: ShapeKind -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ShapeKind) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ShapeKind) # gmapT :: (forall b. Data b => b -> b) -> ShapeKind -> ShapeKind # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ShapeKind -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ShapeKind -> r # gmapQ :: (forall d. Data d => d -> u) -> ShapeKind -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ShapeKind -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ShapeKind -> m ShapeKind # | |
| Show ShapeKind Source # | |
| Eq ShapeKind Source # | |
| Ord ShapeKind Source # | |
Abstract representation of angles. Rotation is divided into four equal sections on the unit circle.
Instances
| Data Angle Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Angle -> c Angle # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Angle # dataTypeOf :: Angle -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Angle) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Angle) # gmapT :: (forall b. Data b => b -> b) -> Angle -> Angle # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Angle -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Angle -> r # gmapQ :: (forall d. Data d => d -> u) -> Angle -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Angle -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Angle -> m Angle # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Angle -> m Angle # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Angle -> m Angle # | |
| Show Angle Source # | |
| Eq Angle Source # | |
| Ord Angle Source # | |
Abstract representation of scaling factors. Considers values equal if both are scaled larger, smaller or not at all.
Instances
| Data Factor Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Factor -> c Factor # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Factor # toConstr :: Factor -> Constr # dataTypeOf :: Factor -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Factor) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Factor) # gmapT :: (forall b. Data b => b -> b) -> Factor -> Factor # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Factor -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Factor -> r # gmapQ :: (forall d. Data d => d -> u) -> Factor -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Factor -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Factor -> m Factor # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Factor -> m Factor # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Factor -> m Factor # | |
| Show Factor Source # | |
| Eq Factor Source # | |
| Ord Factor Source # | |
Abstract representation of translations. Considers values equal if both are translated by a positive or negative number or not at all.
Instances
| Data Position Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position # toConstr :: Position -> Constr # dataTypeOf :: Position -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Position) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) # gmapT :: (forall b. Data b => b -> b) -> Position -> Position # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r # gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position # | |
| Num Position Source # | |
| Show Position Source # | |
| Eq Position Source # | |
| Ord Position Source # | |
Defined in CodeWorld.Test.AbsTypes | |
Abstract representation of points in 2D space. All values are considered equal.
Instances
| Data AbsPoint Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbsPoint -> c AbsPoint # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbsPoint # toConstr :: AbsPoint -> Constr # dataTypeOf :: AbsPoint -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbsPoint) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbsPoint) # gmapT :: (forall b. Data b => b -> b) -> AbsPoint -> AbsPoint # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbsPoint -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbsPoint -> r # gmapQ :: (forall d. Data d => d -> u) -> AbsPoint -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> AbsPoint -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsPoint -> m AbsPoint # | |
| Show AbsPoint Source # | |
| Eq AbsPoint Source # | |
| Ord AbsPoint Source # | |
Defined in CodeWorld.Test.AbsTypes | |
Abstract representation of Color.
Equal if each HSLA parameter has an acceptable distance from those of the other color.
Instances
| Data AbsColor Source # | |
Defined in CodeWorld.Test.AbsTypes Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AbsColor -> c AbsColor # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AbsColor # toConstr :: AbsColor -> Constr # dataTypeOf :: AbsColor -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AbsColor) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AbsColor) # gmapT :: (forall b. Data b => b -> b) -> AbsColor -> AbsColor # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AbsColor -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AbsColor -> r # gmapQ :: (forall d. Data d => d -> u) -> AbsColor -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> AbsColor -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AbsColor -> m AbsColor # | |
| Show AbsColor Source # | |
| Eq AbsColor Source # | |
| Ord AbsColor Source # | |
Defined in CodeWorld.Test.AbsTypes | |
Spatial View
Aside from normalizing the picture and retrieving (individual) parameters, we also want to inspect how components are laid out on the canvas and query their parameters as a whole. The following data types and functions implement this more zoomed out approach.
data RelativePicSpec Source #
Abstract representation of spatial positioning between two picture components.
Instances
| Show RelativePicSpec Source # | |
Defined in CodeWorld.Test.Relative Methods showsPrec :: Int -> RelativePicSpec -> ShowS # show :: RelativePicSpec -> String # showList :: [RelativePicSpec] -> ShowS # | |
| Eq RelativePicSpec Source # | |
Defined in CodeWorld.Test.Relative Methods (==) :: RelativePicSpec -> RelativePicSpec -> Bool # (/=) :: RelativePicSpec -> RelativePicSpec -> Bool # | |
| Ord RelativePicSpec Source # | |
Defined in CodeWorld.Test.Relative Methods compare :: RelativePicSpec -> RelativePicSpec -> Ordering # (<) :: RelativePicSpec -> RelativePicSpec -> Bool # (<=) :: RelativePicSpec -> RelativePicSpec -> Bool # (>) :: RelativePicSpec -> RelativePicSpec -> Bool # (>=) :: RelativePicSpec -> RelativePicSpec -> Bool # max :: RelativePicSpec -> RelativePicSpec -> RelativePicSpec # min :: RelativePicSpec -> RelativePicSpec -> RelativePicSpec # | |
type SpatialQuery = [RelativePicSpec] -> Bool Source #
Alias for queries on spatial relationships.
isSouthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is below the second and aligned on the X-axis.
isNorthOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is above the second and aligned on the X-axis.
isWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is left of the second and aligned on the Y-axis.
isEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is right of the second and aligned on the Y-axis.
isSouthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is below and to the right of the second.
isSouthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is below and to the left of the second.
isNorthEastOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is above and to the right of the second.
isNorthWestOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is above and to the left of the second.
isBelow :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is below the second, ignoring horizontal positioning.
isAbove :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is above the second, ignoring horizontal positioning.
isLeftOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is left of the second, ignoring vertical positioning.
isRightOf :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is right of the second, ignoring vertical positioning.
atSamePosition :: AbstractPicture -> AbstractPicture -> SpatialQuery Source #
True if the first argument is at the same position as the second.
Predicates on Components
data Components Source #
Abstract representation of a picture in terms of its components and the pairwise spatial positioning between them.
Instances
| Show Components Source # | |
Defined in CodeWorld.Test.Relative Methods showsPrec :: Int -> Components -> ShowS # show :: Components -> String # showList :: [Components] -> ShowS # | |
| Eq Components Source # | |
Defined in CodeWorld.Test.Relative | |
| Ord Components Source # | |
Defined in CodeWorld.Test.Relative Methods compare :: Components -> Components -> Ordering # (<) :: Components -> Components -> Bool # (<=) :: Components -> Components -> Bool # (>) :: Components -> Components -> Bool # (>=) :: Components -> Components -> Bool # max :: Components -> Components -> Components # min :: Components -> Components -> Components # | |
type StaticImage = (Picture, Components) Source #
The environment for tests on still images.
type Animation = Double -> StaticImage Source #
The environment for tests on animations.
containsElem :: MonadReader StaticImage m => AbstractPicture -> m Bool Source #
True if image contains at least this subpicture and optionally something else.
containsElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool Source #
True if image contains at least these subpictures and optionally something else.
containsExactElems :: MonadReader StaticImage m => [AbstractPicture] -> m Bool Source #
True if image contains exactly these subpictures and nothing else.
thisOften :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #
True if image contains this subpicture exactly this many times.
atLeast :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #
True if image contains this subpicture at least this many times.
atMost :: MonadReader StaticImage m => AbstractPicture -> Int -> m Bool Source #
True if image contains this subpicture at most many times.
inRangeOf :: MonadReader StaticImage m => AbstractPicture -> (Int, Int) -> m Bool Source #
True if amount of times this subpicture is contained in the image lies in the specified range.
hasRelation :: MonadReader StaticImage m => SpatialQuery -> m Bool Source #
(<||>) :: MonadReader env m => m Bool -> m Bool -> m Bool Source #
At least one of two predicates evaluates to True.
(<^^>) :: MonadReader env m => m Bool -> m Bool -> m Bool Source #
Only one of two predicates evaluate to True (XOR).
options :: MonadReader env m => [m Bool] -> m Bool Source #
At least one of many predicates evaluates to True.
oneOf :: MonadReader env m => (a -> m Bool) -> [a] -> m Bool Source #
The predicate is satisfied by at least one of the given options. Use when there's multiple shape primitives a student could use to solve the task.
Queries on Components
rawImage :: MonadReader StaticImage m => m Picture Source #
Returns the unmodified Picture.
normalizedImage :: MonadReader StaticImage m => m Picture Source #
Returns the normalized Picture.
findAll :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture] Source #
Returns all subpictures satisfying the predicate. (translation is removed)
findAllThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a] Source #
Finds all subpictures satisfying a predicate, then applies a function. (translation is removed)
findAllTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m [AbstractPicture] Source #
Returns all subpictures satisfying the predicate. (includes translation)
findAllTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m [a] Source #
Finds all subpictures satisfying a predicate, then applies a function. (includes translation)
findFirst :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture) Source #
Returns the first subpictures satisfying the predicate if it exists. (translation is removed)
findFirstThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a) Source #
Finds the first subpictures satisfying a predicate, then applies a function if it exists. (translation is removed)
findFirstTranslated :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> m (Maybe AbstractPicture) Source #
Returns the first subpicture satisfying the predicate if it exists. (includes translation)
findFirstTranslatedThen :: MonadReader StaticImage m => (AbstractPicture -> Bool) -> (AbstractPicture -> a) -> m (Maybe a) Source #
Finds the first subpicture satisfying a predicate, then applies a function if it exists. (includes translation)
Helpers for Animations
mapAnimation :: MonadReader Animation m => (StaticImage -> a) -> m (Double -> a) Source #
Returns the animation environment with its output mapped over by the argument.
atTime :: forall (m :: Type -> Type) a. Double -> ReaderT StaticImage m a -> ReaderT Animation m a Source #
Samples the animation at the given time point and applies a predicate or query to it.
rawImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture] Source #
Samples the animation at multiple time points and returns a list of unmodified results.
normalizedImagesAt :: forall (m :: Type -> Type). Monad m => [Double] -> ReaderT Animation m [Picture] Source #
Samples the animation at multiple time points and returns a list of normalized results.
anyAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #
Samples the animation at multiple time points and applies a predicate to each image.
Returns True if any sample satisfied the predicate.
allAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #
Samples the animation at multiple time points and applies a predicate to each image.
Returns True if all samples satisfied the predicate.
allAtWithTime :: [Double] -> (Double -> Reader StaticImage Bool) -> Reader Animation Bool Source #
Samples the animation at multiple time points
and applies a predicate dependent on the current time point to each image.
Returns True if all samples satisfied the predicate.
noneAt :: [Double] -> Reader StaticImage Bool -> Reader Animation Bool Source #
Samples the animation at multiple time points and applies a predicate to each image.
Returns True if none of the samples satisfied the predicate.
queryAt :: forall (m :: Type -> Type) a. Applicative m => [Double] -> ReaderT StaticImage m a -> ReaderT Animation m [a] Source #
Samples the animation at multiple time points and applies a predicate or query to each image, then returns a list of results.
Running Tests
complain :: String -> Reader env Bool -> ReaderT env (Except String) () Source #
Builds a fallible test given an error message and a predicate.
testPicture :: Picture -> ReaderT StaticImage (Except String) () -> String Source #
Executes the given test suite on a static image and returns the error message of the first failed test or the empty String if all tests passed.
testAnimation :: (Double -> Picture) -> ReaderT Animation (Except String) () -> String Source #
Executes the given test suite on an animation and returns the error message of the first failed test or the empty String if all tests passed.
Strict Pictures
Exposed internals of the student facing Picture type.
This is useful if specific attributes can be determined directly from the un-normalized syntax tree.
Primitives from Uniplate can then be employed
to generically traverse the structure.
Type Internals
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.
Bundled Patterns
Instances
| MuRef Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture Associated Types
| |||||
| NFData Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
| 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 # | |||||
Defined in CodeWorld.Tasks.Picture Associated Types
| |||||
| Show Picture Source # | |||||
| Eq Picture Source # | |||||
| Ord Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
| type DeRef Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture | |||||
| type Rep Picture Source # | |||||
Defined in CodeWorld.Tasks.Picture type Rep Picture = D1 ('MetaData "Picture" "CodeWorld.Tasks.Picture" "codeworld-tasks-0.1.0.0-HDTRBEVOXsr1YTQ9DZ9YSS" 'True) (C1 ('MetaCons "PRec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ReifyPicture Picture)))) | |||||
Misc. Functions for Pictures
hasInnerPicture :: Picture -> Bool Source #
innerPicture :: Picture -> Picture Source #
isIn :: Picture -> (Point, Point) -> Bool Source #
Checks if the argument is contained completely inside a box. The coordinates of the box are given as two points with the following format:
- (minimum x-value, maximum x-value)
- (minimum y-value, maximum y-value)
Test Utility
Miscellaneous functions to use in tests.
Type Conversions
normalize :: Picture -> Picture Source #
Apply a set of rewriting rules to the Picture's syntax tree. The result is a normalized and simplified tree in canonical form, which draws the same image.
normalizeNoOrder :: Picture -> Picture Source #
Same as normalize,
but also erases information on which subpictures are drawn in front or behind others.
normalizeAndAbstract :: Picture -> AbstractPicture Source #
Apply a set of rewriting rules to the Picture's syntax tree,
then abstract concrete parameters of the nodes,
resulting in an AbstractPicture.
The new tree is normalized, simplified and allows for more fuzzy comparisons and queries.
toConcretePicture :: AbstractPicture -> Picture Source #
Transform an AbstractPicture into a Picture.
Used to compare normalized sample solution to student submission in plain form.
This only makes sense if there's exactly one way to solve the given task.
Functions for Point-based Shapes
Point list based shapes like curve, polyline or polygon differ from other basic shapes
in that they can be drawn anywhere instead of only in a fixed position in the origin.
Conventional detection of translation, rotation or scaling is thus not possible.
These functions help remedy this problem by comparing two point lists
to see if a transformation was applied to one to get the other.
wasTranslatedBy :: [Point] -> [Point] -> Maybe Point Source #
Returns which translation needs to be applied to argument 1 to get argument 2. Nothing if the polygons are different.
This can be used to detect translation in point list based shapes.
wasScaledBy :: [Point] -> [Point] -> Maybe (Maybe Double, Maybe Double) Source #
Returns which scaling factors need to be applied to argument 1 to get argument 2.
- Nothing if the polygons are not similar.
- Factors themselves can also be Nothing if the factor is undeterminable.
E.g. a possible result could be Just (Just 3, Nothing).
This means the second shape is a scaled version of the first and the factor in X-direction is 3,
but the factor in Y-direction cannot be determined.
This can be used to detect size scaling in point list based shapes.
wasRotatedBy :: [Point] -> [Point] -> Maybe Double Source #
Returns which rotation needs to be applied to argument 1 to get argument 2. Nothing if it does not exist.
This can be used to detect rotation in point list based shapes.
Animation Test Frame Generators
irregularSamples :: [Double] Source #
An infinite list of animation sampling points. The basis is made of irrational square roots, exp(1) and π. The provided samples should not overlap with any particular phase a student submitted animation may have.
samplesUntil :: Double -> Double -> [Double] Source #
Generates irregular sample frames starting from 0 with given step size and cutoff point. The step size is only an approximation, since the generated values are based on irrational numbers.
CSE detection
testCSE :: Picture -> IO (Maybe String) Source #
Produce student feedback on common subexpression elimination for a Picture value.
This compares the results of the Hashcons and Reify methods to determine unused sharing potential.
Returns Nothing if all possible terms are shared.
This runs in an IO context, since Reify uses StableName to track sharing.
Re-exports of CodeWorld Interface
Pictures
rectangle :: Double -> Double -> Picture Source #
Draw a hollow, thin 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).
solidRectangle :: Double -> Double -> Picture Source #
Draw a filled in rectangle with this length and height.
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).
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.
thickPolygon :: Double -> [Point] -> Picture Source #
Same as thickPolyline 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.
scaled :: Double -> Double -> Picture -> Picture Source #
Scale the image in x and y-directions using these modifiers.
dilated :: Double -> Picture -> Picture Source #
Scale the image in both directions using the same modifier.
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.
(&) :: Picture -> Picture -> Picture Source #
Compose two Pictures.
The left argument will be drawn on top of the right argument if they overlap.
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.
Math
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
| NFData Font Source # | |||||
Defined in CodeWorld.Tasks.Types | |||||
| 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 # | |||||
| 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-HDTRBEVOXsr1YTQ9DZ9YSS" '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
| NFData TextStyle Source # | |||||
Defined in CodeWorld.Tasks.Types | |||||
| 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 # | |||||
| 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-HDTRBEVOXsr1YTQ9DZ9YSS" '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))) | |||||
Colour
Color type mirroring CodeWorld's equivalent type. The exposed constructors allow for setting colors directly via numerical values.
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.