Class: Toybox.Graphics.Dc
- Inherits:
-
Toybox.Lang.Object
Overview
This class represents a device context.
It provides methods to perform drawing operations on the device.
You should never directly instantiate a Dc object, or attempt to render to the screen outside of an onUpdate call.
Instance Method Summary collapse
-
clear()
Erase the screen using the background color.
-
clearClip()
Reset the drawable area to the full area of the Dc.
-
drawArc(x, y, r, attr, degreeStart, degreeEnd)
Draw an arc.
-
drawBitmap(x, y, bitmap)
Draw a bitmap to the screen.
-
drawCircle(x, y, radius)
Draw a circle around a point.
-
drawEllipse(x, y, a, b)
Draw an ellipse around a point.
-
drawLine(x1, y1, x2, y2)
Draw a line between two points.
-
drawPoint(x, y)
Draw a point on the screen.
-
drawRectangle(x, y, width, height)
Draw a rectangle.
-
drawRoundedRectangle(x, y, width, height, radius)
Draw a rounded rectangle.
-
drawText(x, y, font, text, justification)
Draw text at the given location.
-
fillCircle(x, y, radius)
Fill a circle with the foreground color.
-
fillEllipse(x, y, a, b)
Fill an ellipse with the foreground color.
-
fillPolygon(pts)
Fill a polygon with the foreground color.
-
fillRectangle(x, y, width, height)
Fill a rectangle with the foreground color.
-
fillRoundedRectangle(x, y, width, height, radius)
Fill a rounded rectangle with the foreground color.
-
getFontHeight(font) ⇒ Toybox.Lang.Number
Get the height of a font.
-
getHeight() ⇒ Toybox.Lang.Number
Get the height of the display region that is available to the app.
-
getTextDimensions(text, font) ⇒ Toybox.Lang.Array
Get the width and height of a String.
-
getTextWidthInPixels(text, font) ⇒ Toybox.Lang.Number
Get the width of a String.
-
getWidth() ⇒ Toybox.Lang.Number
Get the width of the display region that is available to the app.
-
setAntiAlias(enabled)
Enable anti-aliased drawing for primitives This method is not supported for a BufferedBitmap that has a palette.
-
setClip(x, y, width, height)
Apply a clipping region to the Dc.
-
setColor(foreground, background)
Set the current foreground and background colors.
-
setPenWidth(width)
Set the width of a line.
Instance Method Details
clear()
Erase the screen using the background color.
Starting form version 3.1.0, COLOR_TRANSPARENT will also be honored as background color, which will cause the value of pixels in the clip region to be replaced by COLOR_TRANSPARENT. For example, this can be used to clear the transparent overlay layer so animation background is visible.
clearClip()
Reset the drawable area to the full area of the Dc.
drawArc(x, y, r, attr, degreeStart, degreeEnd)
Draw an arc.
-
0 degrees: 3 o'clock position.
-
90 degrees: 12 o'clock position.
-
180 degrees: 9 o'clock position.
-
270 degrees: 6 o'clock position.
drawBitmap(x, y, bitmap)
Draw a bitmap to the screen.
drawCircle(x, y, radius)
Draw a circle around a point.
drawEllipse(x, y, a, b)
Draw an ellipse around a point.
drawLine(x1, y1, x2, y2)
Draw a line between two points.
drawPoint(x, y)
Draw a point on the screen.
drawRectangle(x, y, width, height)
Draw a rectangle.
drawRoundedRectangle(x, y, width, height, radius)
Draw a rounded rectangle.
drawText(x, y, font, text, justification)
Draw text at the given location.
This method is not supported for anti-aliased fonts (including most built in fonts) for a BufferedBitmap that has a palette.
fillCircle(x, y, radius)
Fill a circle with the foreground color.
fillEllipse(x, y, a, b)
Fill an ellipse with the foreground color.
fillPolygon(pts)
Fill a polygon with the foreground color.
fillRectangle(x, y, width, height)
Fill a rectangle with the foreground color.
fillRoundedRectangle(x, y, width, height, radius)
Fill a rounded rectangle with the foreground color.
getFontHeight(font) ⇒ Toybox.Lang.Number
Get the height of a font.
getHeight() ⇒ Toybox.Lang.Number
Get the height of the display region that is available to the app.
getTextDimensions(text, font) ⇒ Toybox.Lang.Array
Get the width and height of a String.
This takes new lines into account when determining the height. The width is the maximum width for a given line of the String. If a String has two newline characters (\\n) in it, the height would be for three lines and the width would be the width of the longest String.
getTextWidthInPixels(text, font) ⇒ Toybox.Lang.Number
Get the width of a String.
getWidth() ⇒ Toybox.Lang.Number
Get the width of the display region that is available to the app.
setAntiAlias(enabled)
Enable anti-aliased drawing for primitives This method is not supported for a BufferedBitmap that has a palette.
setClip(x, y, width, height)
Apply a clipping region to the Dc.
Pixels outside of the region will not be affected by any operations.
setColor(foreground, background)
Set the current foreground and background colors.
setPenWidth(width)
Set the width of a line.