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()
This method preconcats the currentvoidconcat(AffineMatrix*affineMatrix)
AffineMatrix of the ICanvas with the specified matrix.
Parameters
affineMatrix
AffineMatrix* — Required
to preconcatenate with the current AffineMatrix of the ICanvas.
setAffineMatrix()
This method sets the currentvoidsetAffineMatrix(AffineMatrix*affineMatrix)
AffineMatrix of the ICanvas to the specified matrix.
Parameters
affineMatrix
AffineMatrix* — Required
to replace with the current AffineMatrix of the ICanvas.
clipRect()
This method performs intersecting clip operation with the current ICanvas using the specifiedvoidclipRect(Rect*rect)
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()
This method performs intersecting clip operation with the current ICanvas using the specifiedvoidclipRRect(RRect*rRect)
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()
This method performs intersecting clip operation with the current ICanvas clip using the specifiedvoidclipPath(IPath*path)
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()
This method draws the specifiedvoiddrawRect(Rect*rect,IPaint*paint)
Rect using the specified IPaint.
Parameters
rect
Rect* — Required
Rect to be drawn
paint
IPaint* — Required
IPaint instance to draw the Rect.
drawRRect()
This method draws the specifiedvoiddrawRRect(RRect*rRect,IPaint*paint)
RRect using the specified IPaint.
Parameters
rRect
RRect* — Required
RRect to be drawn
paint
IPaint* — Required
IPaint instance to draw the RRect.
drawCircle()
This method draws the circle using the specifiedvoiddrawCircle(Pointcenter,floatradius,IPaint*paint)
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()
This method draws the specifiedvoiddrawPath(IPath*path,IPaint*paint)
IPath using the specified IPaint.
Parameters
path
IPath* — Required
IPath to be drawn
paint
IPaint* — Required
IPaint instance to draw the IPath.
rotateDegrees()
This method preconcats the currentvoidrotateDegrees(floatdegrees,Pointpivot)
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
InvalidOperationError— If it is called more times thanICanvas::savewas called.
restoreToCount()
This method is an efficient way to pop any calls tovoidrestoreToCount(u32saveCount)
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()
This method preconcats the currentvoidscale(floatscaleX,floatscaleY)
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()
This method preconcats the currentvoidtranslate(Pointdistance)
AffineMatrix with the specified translation
Parameters
distance
Point — Required
distance to translate on both x-axis and y-axis
drawOval()
This method draws the specified oval using the specifiedvoiddrawOval(Rect*oval,IPaint*paint)
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()
This method behaves the same asu32saveLayerAlpha(Rect*bounds,floatalpha)
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().

