Child pages
  • Graphics
Skip to end of metadata
Go to start of metadata

This module can be used draw on the display.

Depending on the display driver the draw functions do not necessarily update the display immediately and might only schedule the operation. Call the flush function to update the display after calling any of the draw functions.
Graphics function can be used inside the paint function of a Widget.
Following image ilustrates the coordinate system:

Functions

  .drawLine( x0, y0, x1, y1, color )

Draws a line. The line is drawn from coordinates (x0,y0) to coordinates (x1,y1).

Parameter
Type
Description
x0NumberStart coordinate on X-axis.
y0Number

Start coordinate on Y-axis.

x1NumberEnd coordinate on X-axis.
y1NumberEnd coordinate on Y-axis.
colorColorColor of the line

No return value.

.drawRectangle ( x, y, width, height, color, fill )

Draws a rectangle. The rectangle can optionally be filled.

Parameter
Type
Description
xNumberLeft coordinate on X-axis.
yNumber

Top coordinate on Y-axis.

widthNumberThe width of the rectangle.
heightNumberThe height of the rectangle.
colorColorColor of the rectangle.
fillBooleanSet to true to fill the rectangle.

No return value.

.drawRoundedRectangle ( x, y, width, height, radius, color, fill )

Draws a rounded rectangle. The rounded rectangle can optionally be filled.

Parameter
Type
Description
xNumberLeft coordinate on X-axis.
yNumber

Top coordinate on Y-axis.

widthNumberThe width of the rectangle.
heightNumberThe height of the rectangle.
radiusNumberRounding radius.
colorColorColor of the rectangle.
fillBooleanSet to true to fill the rectangle.

No return value.

.drawArc ( x, y, radius, startAngle, arcAngle, color, fill )

Draws an arc. The arc can be optionally filled.

Parameter
Type
Description
xNumberArc center coordinate on X-axis.
yNumber

Arc center coordinate on Y-axis.

radiusNumberRadius of the arc.
startAngleNumberStart angle of the arc.
arcAngleNumberAngle of the arc.
colorColorColor of the arc.
fillBooleanSet to true to fill the arc.

No return value.

.drawOval ( x, y, xRadius, yRadius, color, fill )

Draws an oval. The oval can be optionally filled. 

Parameter
Type
Description
xNumberOval center coordinate on X-axis.
yNumber

Oval center coordinate on Y-axis.

xRadiusNumberRadius of the oval on X-axis
yRadiusNumberRadius of the oval on Y-axis.
colorColorColor of the oval.
fillBooleanSet to true to fill the oval.

 No return value.

.drawImage( x, y, width, height, xOffset, yOffset, filename, foreground, background )

Draws an image.

Parameter
Type
Description
xNumberLeft position of the string on X-axis.
yNumber

Top position of the string on Y-axis.

widthNumberWidth of the image.
heightNumberHeight of the image.
xOffsetNumberThe x offset value.
yOffsetNumberThe y offset value.
filenameStringThe filename of the image.
foregroundColorForeground Color of the image.
backgroundColorBackground Color of the image.

 No return value.

The foreground- and background color default to graphics.COLOR_BLACK. If you don't change this, your image might paint completely black!

It's recommended to take a look at the Image module.

.drawString ( x, y, string, font, color )

Draws an oval. The oval can be optionally filled. 

Parameter
Type
Description
xNumberLeft position of the string on X-axis.
yNumber

Top position of the string on Y-axis.

stringStringString to be drawn.
fontFontFont to be used for drawing the text.
colorColorColor of the text.

 No return value.

.stringWidth( font, string )

Returns the width of a string in pixels. The width of a string depends on the Font that is used.

Parameter
Type
Description
fontFontFont to be used for calculating the width.
stringStringString to calculate width of.

Returns a number representing the width of the string in pixels for the given font..


  • No labels