The type image represents a digital raster image. An image is a rectangular area of fixed positive width and height (in pixels). Colors of pixels are represented as 32-bit RGBA colors
.
Definitions on this page will use IMG to represent an arbitrary object
of type image.
Shorthand: w
IMG.width -> int
// Shorthand:
IMG.w -> intThe width of IMG in pixels.
Shorthand: h
IMG.height -> int
// Shorthand:
IMG.h -> intThe height of IMG in pixels.
IMG.dot(color c, int x, int y);Sets the pixel at the position x, y in IMG to the color c.
IMG.draw(image superimposed, int x, int y);Draws the superimposed image onto IMG at the position x, y. The top-left corner of the superimposed image will be placed at the coordinates x, y of IMG.
Note:
The position
x,ymay be outside of the bounds ofIMG, andsuperimposedmay extend beyond the bounds ofIMG.
IMG.fill(color c, int x, int y, int width, int height);Fills a rectangular area of IMG with the color c. The rectangle is defined by its top-left corner at x, y and its dimensions width and height.
Fails:
This function will fail and be skipped over if any of the following conditions are met:
width <= 0height <= 0
IMG.line(color c, float breadth, int x1, int y1, int x2, int y2);Draws a straight line of the color c with a breadth of breadth pixels from x1, y1 to x2, y2 onto IMG.
Fails:
This function will fail and be skipped over if any of the following conditions are met:
breadth < 0.0
IMG.pixel(int x, int y) -> colorReturns the color of the pixel at the position x, y in IMG.
Triggers runtime error(s):
This function will trigger a runtime error that will terminate script execution if any of the following conditions are met:
x < 0y < 0x >= IMG.width:xis greater than or equal to the width ofIMGin pixelsy >= IMG.height:yis greater than or equal to the height ofIMGin pixels
IMG.section(int x, int y, int width, int height) -> imageExtracts and returns a subsection of IMG as a new image. The subsection is defined by the rectangle starting at the position x, y with the specified width and height.
The rectangle may include pixels that are out of bounds of IMG. Such pixels in the returned image will simply be transparent.
Triggers runtime error(s):
This function will trigger a runtime error that will terminate script execution if any of the following conditions are met:
width <= 0height <= 0