Drawing on Images
The getter function .atleast from type
int returns a value greater than the argument.
A getter like .atleast cannot modify the
variable it is acting upon ('val').
The only way to change the variable is to employ the
assignment statement.
A new image is initially fully transparent.
The getter function .fill from type
image returns an image filled with the given color.
A getter like .fill cannot modify the
variable it is acting upon ('canvas').
The only way to change the variable is to employ the
assignment statement.
Auto-assignment makes it easier to draw on an image.
The getter function .text from type
image returns a new image with text drawn on it.
The signature of procedure .text is:
- image image.text(
- point2D position, (top-left corner)
- fontTag font,
- num fontSize,
- colorA color,
- string text
- )
The procedure boxFillp fills a rectangular
area of the screen. The signature of procedure boxFillp is:
- void boxFillp(
- point2D position, (top-left corner)
- vector2D size,
- colorA color
- )
The word void specifies that this procedure does not return a value.
The corresponding member function named .boxFill
is available from type image.
This member function returns the resulting image. Because of this it has a slightly different
signature (it returns a value of type image).
The procedure boxEdgep fills an edge
of a rectangular area.
The signature of procedure boxEdgep is:
- void boxEdgep(
- point2D position, (top-left corner)
- vector2D size,
- num edgeWidth,
- colorA color
- )
The corresponding member function named .boxEdge
is available from type image.
This member function returns the resulting image. Because of this it has a slightly different
signature (it returns a value of type image).
The getter function .crop from type
image returns the specified part of the image.
The signature of this getter function is:
- image image.crop(
- int x, (top)
- int y, (left)
- int sizeX,
- int sizeY
- )
The first word of the signatures specifies the type of the return value.
In other words, this function produces a new value of type image.
All getter functions must return a value.
The name image before the dot specifies what type
does this function belong to.
The getter function .cropResize from type
image returns a specified part of the image
an resizes it to form a new image.
The signature of this getter function is:
- image image.cropResize(
- point2D position, (top-left corner)
- vector2D size,
- int resultSizeX,
- int resultSizeY
- )
The getter function .putImage from type
image puts one image onto another.
The signature of this getter function is:
The getter function .tile from type
image creates a new image
made of tiled copies of another image.
The signature of this getter function is:
- image image.tile(
- int resultSizeX,
- int resultSizeY,
- point2D position
- )
This program creates a small image with a red-blue gradient. It displays the gradient, and also displays
a larger version of the gradient.
It then proceeds to create a large image created by tiling the gradient.
This development of the previous program creates a sprite from the tiled gradient.
It then proceeds animate the the sprite in a circular motion.
This development of the previous program
counter-spins the sprite very fast. It also makes the sprite grow in size
and makes it approach the center of the screen.