Developer   API   Graphics   Canvas

  •  Config(0)
  •  Properties(0)
  •  Methods(21)
  •  Events(0)

Canvas(native)

Canvas encapsulates all states of drawing into a device (bitmap). This includes a reference to the device itself, and a stack of matrix/clip values. For any given draw call (e.g. drawRect), the geometry of the object being drawn is transformed by the concatenation of all the matrices in the stack. The transformed geometry is clipped by the intersection of all of the clips in the stack.

Methods

  • clipRect(left, top, right, bottom, region_op = #intersect) : Canvas
    Modify the current clip with the specified rectangle.
  • concat(matrix) : Canvas
    Preconcat the current matrix with the specified matrix.
  • drawBitmap(bitmap, left, top[, paint]) : Canvas
    Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.
  • drawBitmapMatrix(bitmap, matrix [, paint]) : Canvas
    Function draws bitmap to the canvas to coordinates set by matrix. Matrix contains coordinates of image in source file and also in canvas.
  • drawBitmapNine(bitmap, left, top, right, bottom [,paint = NULL) : Canvas
    Function draws bitmap to client coordinates into canvas. If bitmap resolution is smaller then resolution required by coordinates, bitmap expands in the middle.
  • drawBitmapRect(bitmap, srcLeft, srcTop, srcRight, srcBottom, dstLeft, dstTop, dstRight, dstBottom [, paint]) : Canvas
    Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix.
  • drawCircle(cx, cy, radius, paint) : Canvas
    Draw the specified circle using the specified paint. If radius is <= 0, then nothing will be drawn. The circle will be filled or framed based on the Style in the paint.
  • drawLine(x0, y0, x1, y1, paint) : Canvas
    Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.
  • drawOval(left, top, right, bottom, paint) : Canvas
    Draw the specified oval using the specified paint. The oval will be filled or framed based on the Style in the paint.
  • drawPath(path, paint) : Canvas
    Draw the specified path using the specified paint. The path will be filled or framed based on the Style in the paint.
  • drawPoints(pointMode, points, paint) : Canvas
    Draw a series of points, interpreted based on the PointMode mode.
  • drawRect(left, top, right, bottom, paint) : Canvas
    Draw the specified rectangle using the specified paint. The rectangle will be filled or stroked based on the Style in the paint.
  • drawRoundRect(left, top, right, bottom, rx, ry, paint) : Canvas
    Draw the specified round-rect using the specified paint. The round-rect will be filled or framed based on the Style in the paint.
  • drawText(text, left, top, right, bottom, paint) : Canvas
    Draw text to x, y coordinates.
  • drawTextBox(text, left, top, right, bottom, paint [, align]) : Canvas
    Draw text into the box. The text is cut off by the box dimensions
  • restore() : Canvas
    This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. An error occurs if restore() is called more times than save().
  • rotate(degrees) : Canvas
    Preconcat the current matrix with the specified rotation.
  • save(saveflags = #matrixClip) : Canvas
    This call saves the current matrix and clip information, and pushes a copy onto a private stack. Subsequent calls to translate, scale, rotate, skew, concat or clipRect, clipPath all operate on this copy. When the balancing call to restore() is made, this copy is deleted and the previous matrix/clip state is restored.
  • scale(sx, sy) : Canvas
    Preconcat the current matrix with the specified scale.
  • skew(sx, sy) : Canvas
    Preconcat the current matrix with the specified skew.
  • translate(dx, dy) : Boolean
    Preconcat the current matrix with the specified translation.

Remarks

While the Canvas hold the state of the drawing device, the state (style) of the object being drawn is held by Paint, which is provided as a parameter to each of the draw() methods. Paint holds attributes such as color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), etc.

API Navigation
Skip Navigation Links.
Expand <span>User Interface</span> User Interface
Expand <span>Core & System</span> Core & System
Collapse <span>Graphics</span> Graphics
Canvas
Paint
Bitmap
Typeface
Path
Matrix
Shader
ColorFilter
MaskFilter
Expand <span>Files and Databases</span> Files and Databases
Expand <span>Crypto</span> Crypto
Expand <span>Native User Interface</span> Native User Interface
Expand <span>Net</span> Net
Expand <span>Media</span> Media
Expand <span>Sensor</span> Sensor
Expand <span>Game Development</span> Game Development