drawing_canvas.h

Overview

The drawing_canvas.h file declares the functions related to the canvas in the drawing module.

File to include: <native_drawing/drawing_canvas.h>

Library: libnative_drawing.so

Since: 8

Related module: Drawing

Summary

Enums

Name Description
OH_Drawing_CanvasClipOp {
DIFFERENCE, INTERSECT
}
Enumerates the canvas clipping modes.

Functions

Name Description
OH_Drawing_Canvas * OH_Drawing_CanvasCreate (void) Creates an OH_Drawing_Canvas object.
void OH_Drawing_CanvasDestroy (OH_Drawing_Canvas *) Destroys an OH_Drawing_Canvas object and reclaims the memory occupied by the object.
void OH_Drawing_CanvasBind (OH_Drawing_Canvas *, OH_Drawing_Bitmap *) Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap. (This process is called CPU rendering.)
void OH_Drawing_CanvasAttachPen (OH_Drawing_Canvas *, const OH_Drawing_Pen *) Attaches a pen to a canvas so that the canvas can use the style and color of the pen to outline a shape.
void OH_Drawing_CanvasDetachPen (OH_Drawing_Canvas *) Detaches the pen from a canvas so that the canvas can no longer use the style and color of the pen to outline a shape.
void OH_Drawing_CanvasAttachBrush (OH_Drawing_Canvas *, const OH_Drawing_Brush *) Attaches a brush to a canvas so that the canvas can use the style and color of the brush to fill in a shape.
void OH_Drawing_CanvasDetachBrush (OH_Drawing_Canvas *) Detaches the brush from a canvas so that the canvas can no longer use the style and color of the brush to fill in a shape.
void OH_Drawing_CanvasSave (OH_Drawing_Canvas *) Saves the current canvas status (canvas matrix) to the top of the stack.
void OH_Drawing_CanvasRestore (OH_Drawing_Canvas *) Restores the canvas status (canvas matrix) saved on the top of the stack.
uint32_t OH_Drawing_CanvasGetSaveCount (OH_Drawing_Canvas *) Obtains the number of canvas statuses (canvas matrices) saved in the stack.
void OH_Drawing_CanvasRestoreToCount (OH_Drawing_Canvas *, uint32_t saveCount) Restores to a given number of canvas statuses (canvas matrices).
void OH_Drawing_CanvasDrawLine (OH_Drawing_Canvas *, float x1, float y1, float x2, float y2) Draws a line segment.
void OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas *, const OH_Drawing_Path *) Draws a path.
void OH_Drawing_CanvasDrawBitmap (OH_Drawing_Canvas *, const OH_Drawing_Bitmap *, float left, float top) Draws a bitmap. A bitmap, also referred to as a dot matrix image, a pixel map image, or a grid image, includes single points called pixels (image elements).
void OH_Drawing_CanvasDrawRect (OH_Drawing_Canvas *, const OH_Drawing_Rect *) Draws a rectangle.
void OH_Drawing_CanvasDrawCircle (OH_Drawing_Canvas *, const OH_Drawing_Point *, float radius) Draws a circle.
void OH_Drawing_CanvasDrawOval (OH_Drawing_Canvas *, const OH_Drawing_Rect *) Draws an oval.
void OH_Drawing_CanvasDrawArc (OH_Drawing_Canvas *, const OH_Drawing_Rect *, float startAngle, float sweepAngle) Draws an arc.
void OH_Drawing_CanvasDrawRoundRect (OH_Drawing_Canvas *, const OH_Drawing_RoundRect *) Draws a rounded rectangle.
void OH_Drawing_CanvasDrawTextBlob (OH_Drawing_Canvas *, const OH_Drawing_TextBlob *, float x, float y) Draws a TextBlob.
void OH_Drawing_CanvasClipRect (OH_Drawing_Canvas *, const OH_Drawing_Rect *, OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias) Clips a rectangle.
void OH_Drawing_CanvasClipPath (OH_Drawing_Canvas *, const OH_Drawing_Path *, OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias) Clips a path.
void OH_Drawing_CanvasRotate (OH_Drawing_Canvas *, float degrees, float px, float py) Rotates a canvas by a given angle. A positive number indicates clockwise rotation, and a negative number indicates clockwise rotation.
void OH_Drawing_CanvasTranslate (OH_Drawing_Canvas *, float dx, float dy) Translates a canvas by a given distance.
void OH_Drawing_CanvasScale (OH_Drawing_Canvas *, float sx, float sy) Scales a canvas.
void OH_Drawing_CanvasClear (OH_Drawing_Canvas *, uint32_t color) Clears a canvas by using a given color.