Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Native
Skip to main content

Interface ICanvas

interface ICanvas
Extends com.amazon.apmf.IStandard ICanvas provides an interface for drawing, and how the drawing is clipped and transformed.

Methods

concat()

void concat(AffineMatrix* affineMatrix)
This method preconcats the current AffineMatrix of the ICanvas with the specified matrix.

Parameters

affineMatrix
AffineMatrix* — Required to preconcatenate with the current AffineMatrix of the ICanvas.

setAffineMatrix()

void setAffineMatrix(AffineMatrix* affineMatrix)
This method sets the current AffineMatrix of the ICanvas to the specified matrix.

Parameters

affineMatrix
AffineMatrix* — Required to replace with the current AffineMatrix of the ICanvas.

clipRect()

void clipRect(Rect* rect)
This method performs intersecting clip operation with the current ICanvas using the specified Rect. Resulting clip will be anti-aliased by default.

Parameters

rect
Rect* — Required The Rect to perform the clip operation with the current clip

clipRRect()

void clipRRect(RRect* rRect)
This method performs intersecting clip operation with the current ICanvas using the specified RRect. Resulting clip will be anti-aliased by default.

Parameters

rRect
RRect* — Required The RRect to perform the clip operation with the current clip

clipPath()

void clipPath(IPath* path)
This method performs intersecting clip operation with the current ICanvas clip using the specified IPath. Resulting clip will be anti-aliased by default.

Parameters

path
IPath* — Required The IPath to perform the clip operation with the current clip

drawRect()

void drawRect(Rect* rect, IPaint* paint)
This method draws the specified Rect using the specified IPaint.

Parameters

rect
Rect* — Required Rect to be drawn
paint
IPaint* — Required IPaint instance to draw the Rect.

drawRRect()

void drawRRect(RRect* rRect, IPaint* paint)
This method draws the specified RRect using the specified IPaint.

Parameters

rRect
RRect* — Required RRect to be drawn
paint
IPaint* — Required IPaint instance to draw the RRect.

drawCircle()

void drawCircle(Point center, float radius, IPaint* paint)
This method draws the circle using the specified IPaint, center and radius.

Parameters

center
Point — Required center of the circle
radius
float — Required radius of the circle
paint
IPaint* — Required IPaint instance to draw the circle

drawPath()

void drawPath(IPath* path, IPaint* paint)
This method draws the specified IPath using the specified IPaint.

Parameters

path
IPath* — Required IPath to be drawn
paint
IPaint* — Required IPaint instance to draw the IPath.

rotateDegrees()

void rotateDegrees(float degrees, Point pivot)
This method preconcats the current AffineMatrix with the specified rotation about a pivot Point at (pivot.x, pivot.y)

Parameters

degrees
float — Required The amount to rotate, in degrees
pivot
Point — Required pivot Point to be used for rotation

save()

u32 save()
This method saves the current AffineMatrix and clip onto a private stack. Subsequent calls to ICanvas::translate, ICanvas::scale, ICanvas::rotateDegrees, ICanvas::concat, ICanvas::clipRect, or ICanvas::clipPath will all operate as usual, but when the balancing call to restore() is made, those calls will be forgotten, and the settings that existed before the save() will be reinstated.

Returns

u32 depth of saved stack.

restore()

void restore()
This method balances a previous call to ICanvas::save, and is used to remove all modifications to the matrix/clip state since the last save call.

Throws


restoreToCount()

void restoreToCount(u32 saveCount)
This method is an efficient way to pop any calls to ICanvas::save that happened after the save count reached saveCount. Does nothing if saveCount is greater than state stack count. Restores state to initial values if saveCount is less than or equal to one.

Parameters

saveCount
u32 — Required The save level to restore to

getSaveCount()

u32 getSaveCount()
This method returns current save count of the canvas stack

Returns

u32 saveCount

scale()

void scale(float scaleX, float scaleY)
This method preconcats the current AffineMatrix with the specified scale.

Parameters

scaleX
float — Required amount to scale on x-axis
scaleY
float — Required amount to scale on y-axis

translate()

void translate(Point distance)
This method preconcats the current AffineMatrix with the specified translation

Parameters

distance
Point — Required distance to translate on both x-axis and y-axis

drawOval()

void drawOval(Rect* oval, IPaint* paint)
This method draws the specified oval using the specified IPaint. The oval will be filled or framed based on the Style in the IPaint.

Parameters

oval
Rect* — Required The bounds of oval used to define the shape and size of the oval.
paint
IPaint* — Required IPaint instance to draw.

saveLayerAlpha()

u32 saveLayerAlpha(Rect* bounds, float alpha)
This method behaves the same as ICanvas::save, but in addition it allocates and redirects drawing to an offscreen rendering target. All drawing calls are directed to a newly allocated offscreen rendering target. Only when the balancing call to ICanvas::restore is made, is that offscreen buffer drawn back to the current target of the ICanvas (which can potentially be a previous layer if these calls are nested).

Parameters

bounds
Rect* — Required The maximum size the offscreen render target needs to be (in local coordinates)
alpha
float — Required The alpha value to set, specified as a float.

Returns

u32 saveCount value to pass to restoreToCount() to balance this save().
Last modified on October 29, 2026