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() as Void
Erase the screen using the background color.
-
clearClip() as Void
Reset the drawable area to the full area of the Dc.
-
drawAngledText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.VectorFont, text as Lang.String, justification as Graphics.TextJustification or Lang.Number, angle as Lang.Numeric) as Void
Draw angled text Draw text such that it is oriented perpendicular to a radial line at the given angle.
-
drawArc(x as Lang.Numeric, y as Lang.Numeric, r as Lang.Numeric, attr as Graphics.ArcDirection, degreeStart as Lang.Numeric, degreeEnd as Lang.Numeric) as Void
Draw an arc.
-
drawBitmap(x as Lang.Numeric, y as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a bitmap to the screen.
-
drawBitmap2(x as Lang.Numeric, y as Lang.Numeric, bitmap as Graphics.BitmapType, options as { :bitmapX as Lang.Number, :bitmapY as Lang.Number, :bitmapWidth as Lang.Number, :bitmapHeight as Lang.Number, :tintColor as Graphics.ColorType, :filterMode as Graphics.FilterMode, :transform as Graphics.AffineTransform } or Null) as Void
Draw bitmap with the given options.
-
drawCircle(x as Lang.Numeric, y as Lang.Numeric, radius as Lang.Numeric) as Void
Draw a circle around a point.
-
drawEllipse(x as Lang.Numeric, y as Lang.Numeric, a as Lang.Numeric, b as Lang.Numeric) as Void
Draw an ellipse around a point.
-
drawLine(x1 as Lang.Numeric, y1 as Lang.Numeric, x2 as Lang.Numeric, y2 as Lang.Numeric) as Void
Draw a line between two points.
-
drawOffsetBitmap(x as Lang.Numeric, y as Lang.Numeric, bitmapX as Lang.Numeric, bitmapY as Lang.Numeric, bitmapWidth as Lang.Numeric, bitmapHeight as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a bitmap to the screen with an offset.
-
drawPoint(x as Lang.Numeric, y as Lang.Numeric) as Void
Draw a point on the screen.
-
drawRadialText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.VectorFont, text as Lang.String, justification as Graphics.TextJustification or Lang.Number, angle as Lang.Numeric, radius as Lang.Numeric, direction as Graphics.RadialTextDirection) as Void
Draw radial text Draw text oriented along an arc.
-
drawRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Draw a rectangle.
-
drawRoundedRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, radius as Lang.Numeric) as Void
Draw a rounded rectangle.
-
drawScaledBitmap(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a scaled bitmap to a surface.
-
drawText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.FontType, text as Lang.Object or Null, justification as Graphics.TextJustification or Lang.Number) as Void
Draw text at the given location.
-
fillCircle(x as Lang.Numeric, y as Lang.Numeric, radius as Lang.Numeric) as Void
Fill a circle with the foreground color.
-
fillEllipse(x as Lang.Numeric, y as Lang.Numeric, a as Lang.Numeric, b as Lang.Numeric) as Void
Fill an ellipse with the foreground color.
-
fillPolygon(pts as Lang.Array<Graphics.Point2D>) as Void
Fill a polygon with the foreground color.
-
fillRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Fill a rectangle with the foreground color.
-
fillRoundedRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, radius as Lang.Numeric) as Void
Fill a rounded rectangle with the foreground color.
-
getFontHeight(font as Graphics.FontType) as Lang.Number
Get the height of a font.
-
getHeight() as Lang.Number
Get the height of the display region that is available to the app.
-
getTextDimensions(text as Lang.String, font as Graphics.FontType) as [ Lang.Number, Lang.Number ]
Get the width and height of a String.
-
getTextWidthInPixels(text as Lang.String, font as Graphics.FontType) as Lang.Number
Get the width of a String.
-
getWidth() as Lang.Number
Get the width of the display region that is available to the app.
-
setAntiAlias(enabled as Lang.Boolean) as Void
Enable anti-aliased drawing for primitives This method is not supported for a BufferedBitmap that has a palette.
-
setBlendMode(mode as Graphics.BlendMode) as Void
Set blend mode for drawing.
-
setClip(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Apply a clipping region to the Dc.
-
setColor(foreground as Graphics.ColorType, background as Graphics.ColorType) as Void
Set the current foreground and background colors.
-
setFill(fill as Lang.Number or Graphics.BitmapTexture) as Void
Set fill tool for drawing primitives.
-
setPenWidth(width as Lang.Numeric) as Void
Set the width of a line.
-
setStroke(stroke as Lang.Number or Graphics.BitmapTexture) as Void
Set draw tool for drawing primitives.
Instance Method Details
clear() as Void
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() as Void
Reset the drawable area to the full area of the Dc.
drawAngledText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.VectorFont, text as Lang.String, justification as Graphics.TextJustification or Lang.Number, angle as Lang.Numeric) as Void
Draw angled text
Draw text such that it is oriented perpendicular to a radial line at the given angle.
drawArc(x as Lang.Numeric, y as Lang.Numeric, r as Lang.Numeric, attr as Graphics.ArcDirection, degreeStart as Lang.Numeric, degreeEnd as Lang.Numeric) as Void
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 as Lang.Numeric, y as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a bitmap to the screen.
BitmapReference is only supported in CIQ 4.0.0 and later
drawBitmap2(x as Lang.Numeric, y as Lang.Numeric, bitmap as Graphics.BitmapType, options as { :bitmapX as Lang.Number, :bitmapY as Lang.Number, :bitmapWidth as Lang.Number, :bitmapHeight as Lang.Number, :tintColor as Graphics.ColorType, :filterMode as Graphics.FilterMode, :transform as Graphics.AffineTransform } or Null) as Void
Draw bitmap with the given options
drawCircle(x as Lang.Numeric, y as Lang.Numeric, radius as Lang.Numeric) as Void
Draw a circle around a point.
drawEllipse(x as Lang.Numeric, y as Lang.Numeric, a as Lang.Numeric, b as Lang.Numeric) as Void
Draw an ellipse around a point.
drawLine(x1 as Lang.Numeric, y1 as Lang.Numeric, x2 as Lang.Numeric, y2 as Lang.Numeric) as Void
Draw a line between two points.
drawOffsetBitmap(x as Lang.Numeric, y as Lang.Numeric, bitmapX as Lang.Numeric, bitmapY as Lang.Numeric, bitmapWidth as Lang.Numeric, bitmapHeight as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a bitmap to the screen with an offset.
drawPoint(x as Lang.Numeric, y as Lang.Numeric) as Void
Draw a point on the screen.
drawRadialText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.VectorFont, text as Lang.String, justification as Graphics.TextJustification or Lang.Number, angle as Lang.Numeric, radius as Lang.Numeric, direction as Graphics.RadialTextDirection) as Void
Draw radial text
Draw text oriented along an arc.
drawRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Draw a rectangle.
drawRoundedRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, radius as Lang.Numeric) as Void
Draw a rounded rectangle.
drawScaledBitmap(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, bitmap as Graphics.BitmapType) as Void
Draw a scaled bitmap to a surface.
drawText(x as Lang.Numeric, y as Lang.Numeric, font as Graphics.FontType, text as Lang.Object or Null, justification as Graphics.TextJustification or Lang.Number) as Void
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.
FontReference is only supported in CIQ 4.0.0 and later
fillCircle(x as Lang.Numeric, y as Lang.Numeric, radius as Lang.Numeric) as Void
Fill a circle with the foreground color.
fillEllipse(x as Lang.Numeric, y as Lang.Numeric, a as Lang.Numeric, b as Lang.Numeric) as Void
Fill an ellipse with the foreground color.
fillPolygon(pts as Lang.Array<Graphics.Point2D>) as Void
Fill a polygon with the foreground color.
fillRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Fill a rectangle with the foreground color.
fillRoundedRectangle(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric, radius as Lang.Numeric) as Void
Fill a rounded rectangle with the foreground color.
getFontHeight(font as Graphics.FontType) as Lang.Number
Get the height of a font.
getHeight() as Lang.Number
Get the height of the display region that is available to the app.
getTextDimensions(text as Lang.String, font as Graphics.FontType) as [ Lang.Number, Lang.Number ]
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 as Lang.String, font as Graphics.FontType) as Lang.Number
Get the width of a String.
getWidth() as Lang.Number
Get the width of the display region that is available to the app.
setAntiAlias(enabled as Lang.Boolean) as Void
Enable anti-aliased drawing for primitives This method is not supported for a BufferedBitmap that has a palette.
setBlendMode(mode as Graphics.BlendMode) as Void
Set blend mode for drawing.
BLEND_MODE_NO_BLEND is only supported while drawing bitmaps
setClip(x as Lang.Numeric, y as Lang.Numeric, width as Lang.Numeric, height as Lang.Numeric) as Void
Apply a clipping region to the Dc.
Pixels outside of the region will not be affected by any operations.
setColor(foreground as Graphics.ColorType, background as Graphics.ColorType) as Void
Set the current foreground and background colors.
setFill(fill as Lang.Number or Graphics.BitmapTexture) as Void
Set fill tool for drawing primitives.
this function takes precedence over setColor(). If fill tool is not set, the foreground color will be used.
setPenWidth(width as Lang.Numeric) as Void
Set the width of a line.
setStroke(stroke as Lang.Number or Graphics.BitmapTexture) as Void
Set draw tool for drawing primitives.
this function takes precedence over setColor(). If draw tool is not set, the foreground color will be used.