Drawing

Overview

The Drawing module provides the functions for 2D graphics rendering, text drawing, and image display.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Summary

Files

Name Description
drawing_bitmap.h Declares the functions related to the bitmap in the drawing module.
drawing_brush.h Declares the functions related to the brush in the drawing module.
drawing_canvas.h Declares the functions related to the canvas in the drawing module.
drawing_color.h Declares the functions related to the color in the drawing module.
drawing_color_filter.h Declares the functions related to the color filter in the drawing module.
drawing_filter.h Declares the functions related to the filter in the drawing module.
drawing_font.h Declares the functions related to the font in the drawing module.
drawing_font_collection.h Declares the functions related to the font collection in the drawing module.
drawing_mask_filter.h Declares the functions related to the mask filter in the drawing module.
drawing_matrix.h Declares the functions related to the matrix in the drawing module.
drawing_path.h Declares the functions related to the path in the drawing module.
drawing_pen.h Declares the functions related to the pen in the drawing module.
drawing_point.h Declares the functions related to the coordinate point in the drawing module.
drawing_rect.h Declares the functions related to the rectangle in the drawing module.
drawing_round_rect.h Declares the functions related to the rounded rectangle in the drawing module.
drawing_shader_effect.h Declares the functions related to the shader effect in the drawing module.
drawing_text_blob.h Declares the functions related to the text blob in the drawing module.
drawing_text_declaration.h Declares the structs related to text in 2D drawing.
drawing_text_typography.h Declares the functions related to the typography in the drawing module.
drawing_typeface.h Declares the functions related to the typeface in the drawing module. Different platforms have their own default typefaces. You can also parse the .ttf file to obtain the typefaces specified by the third party, such as SimSun and SimHei.
drawing_types.h Declares the data types of the canvas, brush, pen, bitmap, and path used to draw 2D graphics.

Structs

Name Description
OH_Drawing_BitmapFormat Defines the pixel format of a bitmap, including the color type and alpha type.
OH_Drawing_RunBuffer Describes a run, which provides storage for glyphs and positions.
OH_Drawing_PlaceholderSpan Describes a placeholder that acts as a span.

Types

Name Description
OH_Drawing_FontCollection Defines a font collection, which is used to load fonts.
OH_Drawing_Typography Used to manage the typography layout and display.
OH_Drawing_TextStyle Used to manage text colors and decorations.
OH_Drawing_TypographyStyle Defines the typography style, such as the text direction.
OH_Drawing_TypographyCreate Used to create an OH_Drawing_Typography.
OH_Drawing_TextBox Defines a text box, which is used to receive the rectangle size, direction, and quantity.
OH_Drawing_PositionAndAffinity Used to receive the position and affinity of the graph.
OH_Drawing_Range Defines a range, which is used to receive the start position and end position of the font.
OH_Drawing_Canvas Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen.
OH_Drawing_Pen Defines a pen, which is used to describe the style and color to outline a shape.
OH_Drawing_Brush Defines a brush, which is used to describe the style and color to fill in a shape.
OH_Drawing_Path Defines a path, which is used to customize various shapes.
OH_Drawing_Bitmap Defines a bitmap, which is a memory area that contains the pixel data of a shape.
OH_Drawing_Point Defines a coordinate point.
OH_Drawing_Rect Defines a rectangle.
OH_Drawing_RoundRect Defines a rounded rectangle.
OH_Drawing_Matrix Defines a matrix, which is used to describe coordinate transformation.
OH_Drawing_ShaderEffect Defines a shader effect, which is used to describe the source color of the drawn content.
OH_Drawing_Filter Defines a filter, which consists of a color filter and mask filter.
OH_Drawing_MaskFilter Defines a mask filter, which is used to convert a mask into a new one.
OH_Drawing_ColorFilter Defines a color filter, which is used to convert a color into a new one.
OH_Drawing_Font Defines a font.
OH_Drawing_Typeface Defines a typeface.
OH_Drawing_TextBlob Defines a text blob, which is an immutable container that holds multiple texts. Each text line consists of a glyph and position.
OH_Drawing_TextBlobBuilder Defines a text blob builder, which is used to build a text blob.

Enums

Name Description
OH_Drawing_CanvasClipOp { DIFFERENCE, INTERSECT } Enumerates the canvas clipping modes.
OH_Drawing_BlurType { NORMAL, SOLID, OUTER, INNER } Enumerates the blur types.
OH_Drawing_PenLineCapStyle { LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP } Enumerates the line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen.
OH_Drawing_PenLineJoinStyle { LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN } Enumerates the line join styles of a pen. The line join style defines the shape of the joints of a polyline segment drawn by the pen.
OH_Drawing_TileMode { CLAMP, REPEAT, MIRROR, DECAL } Enumerates the tile modes of the shader effect.
OH_Drawing_TextDirection { TEXT_DIRECTION_RTL, TEXT_DIRECTION_LTR } Enumerates the text directions.
OH_Drawing_TextAlign {
TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY,
TEXT_ALIGN_START, TEXT_ALIGN_END
}
Enumerates the text alignment modes.
OH_Drawing_FontWeight {
FONT_WEIGHT_100, FONT_WEIGHT_200, FONT_WEIGHT_300, FONT_WEIGHT_400,
FONT_WEIGHT_500, FONT_WEIGHT_600, FONT_WEIGHT_700, FONT_WEIGHT_800,
FONT_WEIGHT_900
}
Enumerates the font weights.
OH_Drawing_TextBaseline {
TEXT_BASELINE_ALPHABETIC, TEXT_BASELINE_IDEOGRAPHIC
}
Enumerates the text baselines.
OH_Drawing_TextDecoration {
TEXT_DECORATION_NONE = 0x0, TEXT_DECORATION_UNDERLINE = 0x1, TEXT_DECORATION_OVERLINE = 0x2, TEXT_DECORATION_LINE_THROUGH = 0x4
}
Enumerates the text decorations.
OH_Drawing_FontStyle {
FONT_STYLE_NORMAL, FONT_STYLE_ITALIC
}
Enumerates the font styles.
OH_Drawing_PlaceholderVerticalAlignment {
ALIGNMENT_OFFSET_AT_BASELINE, ALIGNMENT_ABOVE_BASELINE, ALIGNMENT_BELOW_BASELINE, ALIGNMENT_TOP_OF_ROW_BOX,
ALIGNMENT_BOTTOM_OF_ROW_BOX, ALIGNMENT_CENTER_OF_ROW_BOX
}
Enumerates the vertical alignment modes of placeholders.
OH_Drawing_TextDecorationStyle {
TEXT_DECORATION_STYLE_SOLID, TEXT_DECORATION_STYLE_DOUBLE, TEXT_DECORATION_STYLE_DOTTED, TEXT_DECORATION_STYLE_DASHED,
TEXT_DECORATION_STYLE_WAVY
}
Enumerates the text decoration styles.
OH_Drawing_EllipsisModal {
ELLIPSIS_MODAL_HEAD = 0, ELLIPSIS_MODAL_MIDDLE = 1, ELLIPSIS_MODAL_TAIL = 2
}
Enumerates the ellipsis styles.
OH_Drawing_BreakStrategy {
BREAK_STRATEGY_GREEDY = 0, BREAK_STRATEGY_HIGH_QUALITY = 1, BREAK_STRATEGY_BALANCED = 2
}
Enumerates the text break strategies.
OH_Drawing_WordBreakType {
WORD_BREAK_TYPE_NORMAL = 0, WORD_BREAK_TYPE_BREAK_ALL = 1, WORD_BREAK_TYPE_BREAK_WORD = 2
}
Enumerates the word break types.
OH_Drawing_RectHeightStyle {
RECT_HEIGHT_STYLE_TIGHT, RECT_HEIGHT_STYLE_MAX, RECT_HEIGHT_STYLE_INCLUDELINESPACEMIDDLE, RECT_HEIGHT_STYLE_INCLUDELINESPACETOP,
RECT_HEIGHT_STYLE_INCLUDELINESPACEBOTTOM, RECT_HEIGHT_STYLE_STRUCT
}
Enumerates the rectangle height styles.
OH_Drawing_RectWidthStyle {
RECT_WIDTH_STYLE_TIGHT, RECT_WIDTH_STYLE_MAX
}
Enumerates the rectangle width styles.
OH_Drawing_ColorFormat {
COLOR_FORMAT_UNKNOWN, COLOR_FORMAT_ALPHA_8, COLOR_FORMAT_RGB_565, COLOR_FORMAT_ARGB_4444,
COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888
}
Enumerates the storage formats of bitmap pixels.
OH_Drawing_AlphaFormat {
ALPHA_FORMAT_UNKNOWN, ALPHA_FORMAT_OPAQUE, ALPHA_FORMAT_PREMUL, ALPHA_FORMAT_UNPREMUL
}
Enumerates the alpha formats of bitmap pixels.
OH_Drawing_BlendMode {
BLEND_MODE_CLEAR, BLEND_MODE_SRC, BLEND_MODE_DST, BLEND_MODE_SRC_OVER,
BLEND_MODE_DST_OVER, BLEND_MODE_SRC_IN, BLEND_MODE_DST_IN, BLEND_MODE_SRC_OUT,
BLEND_MODE_DST_OUT, BLEND_MODE_SRC_ATOP, BLEND_MODE_DST_ATOP, BLEND_MODE_XOR,
BLEND_MODE_PLUS, BLEND_MODE_MODULATE, BLEND_MODE_SCREEN, BLEND_MODE_OVERLAY,
BLEND_MODE_DARKEN, BLEND_MODE_LIGHTEN, BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN,
BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE, BLEND_MODE_EXCLUSION,
BLEND_MODE_MULTIPLY, BLEND_MODE_HUE, BLEND_MODE_SATURATION, BLEND_MODE_COLOR,
BLEND_MODE_LUMINOSITY
}
Enumerates the blend modes. In blend mode, each operation generates a new color from two colors (source color and target color). These operations are the same on the four channels (red, green, blue, and alpha). The operations for the alpha channel are used as examples.

Functions

Name Description
OH_Drawing_Bitmap * OH_Drawing_BitmapCreate (void) Creates an OH_Drawing_Bitmap object.
void OH_Drawing_BitmapDestroy (OH_Drawing_Bitmap *) Destroys an OH_Drawing_Bitmap object and reclaims the memory occupied by the object.
void OH_Drawing_BitmapBuild (OH_Drawing_Bitmap *, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat *) Initializes the width and height of a bitmap and sets the pixel format for the bitmap.
uint32_t OH_Drawing_BitmapGetWidth (OH_Drawing_Bitmap *) Obtains the width of a bitmap.
uint32_t OH_Drawing_BitmapGetHeight (OH_Drawing_Bitmap *) Obtains the height of a bitmap.
void * OH_Drawing_BitmapGetPixels (OH_Drawing_Bitmap *) Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap.
OH_Drawing_Brush * OH_Drawing_BrushCreate (void) Creates an OH_Drawing_Brush object.
void OH_Drawing_BrushDestroy (OH_Drawing_Brush *) Destroys an OH_Drawing_Brush object and reclaims the memory occupied by the object.
bool OH_Drawing_BrushIsAntiAlias (const OH_Drawing_Brush *) Checks whether anti-aliasing is enabled for a brush. Anti-aliasing makes the pixels around the shape edges semi-transparent.
void OH_Drawing_BrushSetAntiAlias (OH_Drawing_Brush *, bool) Enables or disables anti-aliasing for a brush. Anti-aliasing makes the pixels around the shape edges semi-transparent.
uint32_t OH_Drawing_BrushGetColor (const OH_Drawing_Brush *) Obtains the color of a brush. The color is used by the brush to fill in a shape.
void OH_Drawing_BrushSetColor (OH_Drawing_Brush *, uint32_t color) Sets the color for a brush. The color is used by the brush to fill in a shape.
uint8_t OH_Drawing_BrushGetAlpha (const OH_Drawing_Brush *) Obtains the alpha value of a brush. This value is used by the alpha channel when the brush fills in a shape.
void OH_Drawing_BrushSetAlpha (OH_Drawing_Brush *, uint8_t alpha) Sets the alpha value for a brush. This value is used by the alpha channel when the brush fills in a shape.
void OH_Drawing_BrushSetShaderEffect (OH_Drawing_Brush *, OH_Drawing_ShaderEffect *) Sets the shader effect for a brush.
void OH_Drawing_BrushSetFilter (OH_Drawing_Brush *, OH_Drawing_Filter *) Sets a filter for a brush. The filter is a container that holds a mask filter and color filter.
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 text blob.
uint32_t OH_Drawing_ColorSetArgb (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateBlendMode (uint32_t color, OH_Drawing_BlendMode) Creates an OH_Drawing_ColorFilter object with a given blend mode.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateCompose (OH_Drawing_ColorFilter *colorFilter1, OH_Drawing_ColorFilter *colorFilter2) Creates an OH_Drawing_ColorFilter object by combining another two color filters.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateMatrix (const float matrix[20]) Creates an OH_Drawing_ColorFilter object with a given 5x4 color matrix.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateLinearToSrgbGamma (void) Creates an OH_Drawing_ColorFilter object that applies the sRGB gamma curve to the RGB channels.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateSrgbGammaToLinear (void) Creates an OH_Drawing_ColorFilter object that applies the RGB channels to the sRGB gamma curve.
OH_Drawing_ColorFilter * OH_Drawing_ColorFilterCreateLuma (void) Creates an OH_Drawing_ColorFilter object that multiplies the passed-in luma into the alpha channel and sets the RGB channels to zero.
void OH_Drawing_ColorFilterDestroy (OH_Drawing_ColorFilter *) Destroys an OH_Drawing_ColorFilter object and reclaims the memory occupied by the object.
OH_Drawing_Filter * OH_Drawing_FilterCreate (void) Creates an OH_Drawing_Filter object.
void OH_Drawing_FilterSetMaskFilter (OH_Drawing_Filter *, OH_Drawing_MaskFilter *) Sets an OH_Drawing_MaskFilter object for an OH_Drawing_Filter object.
void OH_Drawing_FilterSetColorFilter (OH_Drawing_Filter *, OH_Drawing_ColorFilter *) Sets an OH_Drawing_ColorFilter object for an OH_Drawing_Filter object.
void OH_Drawing_FilterDestroy (OH_Drawing_Filter *) Destroys an OH_Drawing_Filter object and reclaims the memory occupied by the object.
OH_Drawing_Font * OH_Drawing_FontCreate (void) Creates an OH_Drawing_Font object.
void OH_Drawing_FontSetTypeface (OH_Drawing_Font *, OH_Drawing_Typeface *) Sets the typeface for a font.
void OH_Drawing_FontSetTextSize (OH_Drawing_Font *, float textSize) Sets the font size.
void OH_Drawing_FontSetLinearText (OH_Drawing_Font *, bool isLinearText) Sets linear scaling for a font.
void OH_Drawing_FontSetTextSkewX (OH_Drawing_Font *, float skewX) Sets a horizontal skew factor for a font.
void OH_Drawing_FontSetFakeBoldText (OH_Drawing_Font *, bool isFakeBoldText) Sets fake bold for a font by increasing the stroke width.
void OH_Drawing_FontDestroy (OH_Drawing_Font *) Destroys an OH_Drawing_Font object and reclaims the memory occupied by the object.
OH_Drawing_FontCollection * OH_Drawing_CreateFontCollection (void) Creates an OH_Drawing_FontCollection object.
void OH_Drawing_DestroyFontCollection (OH_Drawing_FontCollection *) Destroys an OH_Drawing_FontCollection object and reclaims the memory occupied by the object.
OH_Drawing_MaskFilter * OH_Drawing_MaskFilterCreateBlur (OH_Drawing_BlurType blurType, float sigma, bool respectCTM) Creates an OH_Drawing_MaskFilter object with a given blur type.
void OH_Drawing_MaskFilterDestroy (OH_Drawing_MaskFilter *) Destroys an OH_Drawing_MaskFilter object and reclaims the memory occupied by the object.
OH_Drawing_Matrix * OH_Drawing_MatrixCreate (void) Creates an OH_Drawing_Matrix object.
void OH_Drawing_MatrixSetMatrix (OH_Drawing_Matrix *, float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0, float persp1, float persp2) Sets matrix parameters for an OH_Drawing_Matrix object.
void OH_Drawing_MatrixDestroy (OH_Drawing_Matrix *) Destroys an OH_Drawing_Matrix object and reclaims the memory occupied by the object.
OH_Drawing_Path * OH_Drawing_PathCreate (void) Creates an OH_Drawing_Path object.
void OH_Drawing_PathDestroy (OH_Drawing_Path *) Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object.
void OH_Drawing_PathMoveTo (OH_Drawing_Path *, float x, float y) Sets the start point of a path.
void OH_Drawing_PathLineTo (OH_Drawing_Path *, float x, float y) Draws a line segment from the last point of a path to the target point.
void OH_Drawing_PathArcTo (OH_Drawing_Path *, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added.
void OH_Drawing_PathQuadTo (OH_Drawing_Path *, float ctrlX, float ctrlY, float endX, float endY) Draws a quadratic Bezier curve from the last point of a path to the target point.
void OH_Drawing_PathCubicTo (OH_Drawing_Path *, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) Draws a cubic Bezier curve from the last point of a path to the target point.
void OH_Drawing_PathClose (OH_Drawing_Path *) Closes a path by drawing a line segment from the current point to the start point of the path.
void OH_Drawing_PathReset (OH_Drawing_Path *) Resets path data.
OH_Drawing_Pen * OH_Drawing_PenCreate (void) Creates an OH_Drawing_Pen object.
void OH_Drawing_PenDestroy (OH_Drawing_Pen *) Destroys an OH_Drawing_Pen object and reclaims the memory occupied by the object.
bool OH_Drawing_PenIsAntiAlias (const OH_Drawing_Pen *) Checks whether anti-aliasing is enabled for a pen. Anti-aliasing makes the pixels around the shape edges semi-transparent.
void OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen *, bool) Enables or disables anti-aliasing for a pen. Anti-aliasing makes the pixels around the shape edges semi-transparent.
uint32_t OH_Drawing_PenGetColor (const OH_Drawing_Pen *) Obtains the color of a pen. The color is used by the pen to outline a shape.
void OH_Drawing_PenSetColor (OH_Drawing_Pen *, uint32_t color) Sets the color for a pen. The color is used by the pen to outline a shape.
uint8_t OH_Drawing_PenGetAlpha (const OH_Drawing_Pen *) Obtains the alpha value of a pen. This value is used by the alpha channel when the pen outlines a shape.
void OH_Drawing_PenSetAlpha (OH_Drawing_Pen *, uint8_t alpha) Sets the alpha value for a pen. This value is used by the alpha channel when the pen outlines a shape.
float OH_Drawing_PenGetWidth (const OH_Drawing_Pen *) Obtains the thickness of a pen. This thickness determines the width of the outline of a shape.
void OH_Drawing_PenSetWidth (OH_Drawing_Pen *, float width) Sets the thickness for a pen. This thickness determines the width of the outline of a shape.
float OH_Drawing_PenGetMiterLimit (const OH_Drawing_Pen *) Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.
void OH_Drawing_PenSetMiterLimit (OH_Drawing_Pen *, float miter) Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.
OH_Drawing_PenLineCapStyleOH_Drawing_PenGetCap (const OH_Drawing_Pen *) Obtains the line cap style of a pen.
void OH_Drawing_PenSetCap (OH_Drawing_Pen *, OH_Drawing_PenLineCapStyle) Sets the line cap style for a pen.
OH_Drawing_PenLineJoinStyleOH_Drawing_PenGetJoin (const OH_Drawing_Pen *) Obtains the line join style of a pen.
void OH_Drawing_PenSetJoin (OH_Drawing_Pen *, OH_Drawing_PenLineJoinStyle) Sets the line join style for a pen.
OH_Drawing_Point * OH_Drawing_PointCreate (float x, float y) Creates an OH_Drawing_Point object.
void OH_Drawing_PointDestroy (OH_Drawing_Point *) Destroys an OH_Drawing_Point object and reclaims the memory occupied by the object.
OH_Drawing_Rect * OH_Drawing_RectCreate (float left, float top, float right, float bottom) Creates an OH_Drawing_Rect object.
void OH_Drawing_RectDestroy (OH_Drawing_Rect *) Destroys an OH_Drawing_Rect object and reclaims the memory occupied by the object.
OH_Drawing_RoundRect * OH_Drawing_RoundRectCreate (const OH_Drawing_Rect *, float xRad, float yRad) Creates an OH_Drawing_RoundRect object.
void OH_Drawing_RoundRectDestroy (OH_Drawing_RoundRect *) Destroys an OH_Drawing_RoundRect object and reclaims the memory occupied by the object.
OH_Drawing_ShaderEffect * OH_Drawing_ShaderEffectCreateLinearGradient (const OH_Drawing_Point *startPt, const OH_Drawing_Point *endPt, const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode) Creates an OH_Drawing_ShaderEffect object that generates a linear gradient between two points.
OH_Drawing_ShaderEffect * OH_Drawing_ShaderEffectCreateRadialGradient (const OH_Drawing_Point *centerPt, float radius, const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode) Creates an OH_Drawing_ShaderEffect object that generates a radial gradient based on the center and radius of a circle. The radial gradient transitions colors from the center to the ending shape in a radial manner.
OH_Drawing_ShaderEffect * OH_Drawing_ShaderEffectCreateSweepGradient (const OH_Drawing_Point *centerPt, const uint32_t *colors, const float *pos, uint32_t size, OH_Drawing_TileMode) Creates an OH_Drawing_ShaderEffect object that generates a sweep gradient based on the center.
void OH_Drawing_ShaderEffectDestroy (OH_Drawing_ShaderEffect *) Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object.
OH_Drawing_TextBlobBuilder * OH_Drawing_TextBlobBuilderCreate (void) Creates an OH_Drawing_TextBlobBuilder object.
const OH_Drawing_RunBuffer * OH_Drawing_TextBlobBuilderAllocRunPos (OH_Drawing_TextBlobBuilder *, const OH_Drawing_Font *, int32_t count, const OH_Drawing_Rect *) Allocates a run to store glyphs and positions. The pointer returned does not need to be managed by the caller. It can no longer be used after OH_Drawing_TextBlobBuilderMake is called.
OH_Drawing_TextBlob * OH_Drawing_TextBlobBuilderMake (OH_Drawing_TextBlobBuilder *) Makes an OH_Drawing_TextBlob object from an OH_Drawing_TextBlobBuilder.
void OH_Drawing_TextBlobDestroy (OH_Drawing_TextBlob *) Destroys an OH_Drawing_TextBlob object and reclaims the memory occupied by the object.
void OH_Drawing_TextBlobBuilderDestroy (OH_Drawing_TextBlobBuilder *) Destroys an OH_Drawing_TextBlobBuilder object and reclaims the memory occupied by the object.
OH_Drawing_TypographyStyle * OH_Drawing_CreateTypographyStyle (void) Creates an OH_Drawing_TypographyStyle object.
void OH_Drawing_DestroyTypographyStyle (OH_Drawing_TypographyStyle *) Destroys an OH_Drawing_TypographyStyle object and reclaims the memory occupied by the object.
void OH_Drawing_SetTypographyTextDirection (OH_Drawing_TypographyStyle *, int) Sets the text direction.
void OH_Drawing_SetTypographyTextAlign (OH_Drawing_TypographyStyle *, int) Sets the text alignment mode.
void OH_Drawing_SetTypographyTextMaxLines (OH_Drawing_TypographyStyle *, int) Sets the maximum number of lines in the text.
OH_Drawing_TextStyle * OH_Drawing_CreateTextStyle (void) Creates an OH_Drawing_TextStyle object.
void OH_Drawing_DestroyTextStyle (OH_Drawing_TextStyle *) Destroys an OH_Drawing_TextStyle object and reclaims the memory occupied by the object.
void OH_Drawing_SetTextStyleColor (OH_Drawing_TextStyle *, uint32_t) Sets the text color.
void OH_Drawing_SetTextStyleFontSize (OH_Drawing_TextStyle *, double) Sets the font size.
void OH_Drawing_SetTextStyleFontWeight (OH_Drawing_TextStyle *, int) Sets the font weight.
void OH_Drawing_SetTextStyleBaseLine (OH_Drawing_TextStyle *, int) Sets the text baseline.
void OH_Drawing_SetTextStyleDecoration (OH_Drawing_TextStyle *, int) Sets the text decoration.
void OH_Drawing_SetTextStyleDecorationColor (OH_Drawing_TextStyle *, uint32_t) Sets the color for the text decoration.
void OH_Drawing_SetTextStyleFontHeight (OH_Drawing_TextStyle *, double) Sets the font height.
void OH_Drawing_SetTextStyleFontFamilies (OH_Drawing_TextStyle *, int, const char *fontFamilies[]) Sets the font families.
void OH_Drawing_SetTextStyleFontStyle (OH_Drawing_TextStyle *, int) Sets the font style.
void OH_Drawing_SetTextStyleLocale (OH_Drawing_TextStyle *, const char *) Sets the locale.
OH_Drawing_TypographyCreate * OH_Drawing_CreateTypographyHandler (OH_Drawing_TypographyStyle *, OH_Drawing_FontCollection *) Creates an OH_Drawing_TypographyCreate object.
void OH_Drawing_DestroyTypographyHandler (OH_Drawing_TypographyCreate *) Destroys an OH_Drawing_TypographyCreate object and reclaims the memory occupied by the object.
void OH_Drawing_TypographyHandlerPushTextStyle (OH_Drawing_TypographyCreate *, OH_Drawing_TextStyle *) Sets the text style.
void OH_Drawing_TypographyHandlerAddText (OH_Drawing_TypographyCreate *, const char *) Sets the text content.
void OH_Drawing_TypographyHandlerPopTextStyle (OH_Drawing_TypographyCreate *) Removes the topmost style in the stack, leaving the remaining styles in effect.
OH_Drawing_Typography * OH_Drawing_CreateTypography (OH_Drawing_TypographyCreate *) Creates an OH_Drawing_Typography object.
void OH_Drawing_DestroyTypography (OH_Drawing_Typography *) Destroys an OH_Drawing_Typography object and reclaims the memory occupied by the object.
void OH_Drawing_TypographyLayout (OH_Drawing_Typography *, double) Lays out the typography.
void OH_Drawing_TypographyPaint (OH_Drawing_Typography *, OH_Drawing_Canvas *, double, double) Paints text on the canvas.
double OH_Drawing_TypographyGetMaxWidth (OH_Drawing_Typography *) Obtains the maximum width.
double OH_Drawing_TypographyGetHeight (OH_Drawing_Typography *) Obtains the height.
double OH_Drawing_TypographyGetLongestLine (OH_Drawing_Typography *) Obtains the longest line.
double OH_Drawing_TypographyGetMinIntrinsicWidth (OH_Drawing_Typography *) Obtains the minimum intrinsic width.
double OH_Drawing_TypographyGetMaxIntrinsicWidth (OH_Drawing_Typography *) Obtains the maximum intrinsic width.
double OH_Drawing_TypographyGetAlphabeticBaseline (OH_Drawing_Typography *) Obtains the alphabetic baseline.
double OH_Drawing_TypographyGetIdeographicBaseline (OH_Drawing_Typography *) Obtains the ideographic baseline.
void OH_Drawing_TypographyHandlerAddPlaceholder (OH_Drawing_TypographyCreate *, OH_Drawing_PlaceholderSpan *) Adds a placeholder.
bool OH_Drawing_TypographyDidExceedMaxLines (OH_Drawing_Typography *) Checks whether the maximum number of lines is exceeded.
OH_Drawing_TextBox * OH_Drawing_TypographyGetRectsForRange (OH_Drawing_Typography *, size_t, size_t, OH_Drawing_RectHeightStyle, OH_Drawing_RectWidthStyle) Obtains text boxes in a given range.
OH_Drawing_TextBox * OH_Drawing_TypographyGetRectsForPlaceholders (OH_Drawing_Typography *) Obtains text boxes for placeholders.
float OH_Drawing_GetLeftFromTextBox (OH_Drawing_TextBox *, int) Obtains the left position of a text box.
float OH_Drawing_GetRightFromTextBox (OH_Drawing_TextBox *, int) Obtains the right position of a text box.
float OH_Drawing_GetTopFromTextBox (OH_Drawing_TextBox *, int) Obtains the top position of a text box.
float OH_Drawing_GetBottomFromTextBox (OH_Drawing_TextBox *, int) Obtains the bottom position of a text box.
int OH_Drawing_GetTextDirectionFromTextBox (OH_Drawing_TextBox *, int) Obtains the text direction of a text box.
size_t OH_Drawing_GetSizeOfTextBox (OH_Drawing_TextBox *) Obtains the number of text boxes.
OH_Drawing_PositionAndAffinity * OH_Drawing_TypographyGetGlyphPositionAtCoordinate (OH_Drawing_Typography *, double, double) Obtains the position and affinity of the glyph at the given coordinates.
OH_Drawing_PositionAndAffinity * OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster (OH_Drawing_Typography *, double, double) Obtains the position and affinity of the glyph cluster to which the glyph at the given coordinates belongs. The glyph cluster is a container that holds one or more glyphs.
size_t OH_Drawing_GetPositionFromPositionAndAffinity (OH_Drawing_PositionAndAffinity *) Obtains the position attribute of an OH_Drawing_PositionAndAffinity object.
int OH_Drawing_GetAffinityFromPositionAndAffinity (OH_Drawing_PositionAndAffinity *) Obtains the affinity attribute of an OH_Drawing_PositionAndAffinity object. The affinity determines whether the font is close to the front text or rear text.
OH_Drawing_Range * OH_Drawing_TypographyGetWordBoundary (OH_Drawing_Typography *, size_t) Obtains the word boundary.
size_t OH_Drawing_GetStartFromRange (OH_Drawing_Range *) Obtains the start position of an OH_Drawing_Range object.
size_t OH_Drawing_GetEndFromRange (OH_Drawing_Range *) Obtains the end position of an OH_Drawing_Range object.
size_t OH_Drawing_TypographyGetLineCount (OH_Drawing_Typography *) Obtains the number of lines.
void OH_Drawing_SetTextStyleDecorationStyle (OH_Drawing_TextStyle *, int) Sets the text decoration style.
void OH_Drawing_SetTextStyleDecorationThicknessScale (OH_Drawing_TextStyle *, double) Sets the thickness scale factor of the text decoration line.
void OH_Drawing_SetTextStyleLetterSpacing (OH_Drawing_TextStyle *, double) Sets the letter spacing for text.
void OH_Drawing_SetTextStyleWordSpacing (OH_Drawing_TextStyle *, double) Sets the word spacing for text.
void OH_Drawing_SetTextStyleHalfLeading (OH_Drawing_TextStyle *, bool) Sets half leading for text.
void OH_Drawing_SetTextStyleEllipsis (OH_Drawing_TextStyle *, const char *) Sets the ellipsis content for text.
void OH_Drawing_SetTextStyleEllipsisModal (OH_Drawing_TextStyle *, int) Sets the ellipsis style for text.
void OH_Drawing_SetTypographyTextBreakStrategy (OH_Drawing_TypographyStyle *, int) Sets the text break strategy.
void OH_Drawing_SetTypographyTextWordBreakType (OH_Drawing_TypographyStyle *, int) Sets the word break type.
void OH_Drawing_SetTypographyTextEllipsisModal (OH_Drawing_TypographyStyle *, int) Sets the ellipsis style for text.
double OH_Drawing_TypographyGetLineHeight (OH_Drawing_Typography *, int) Obtains the height of a line.
double OH_Drawing_TypographyGetLineWidth (OH_Drawing_Typography *, int) Obtains the width of a line.
OH_Drawing_Typeface * OH_Drawing_TypefaceCreateDefault (void) Creates an OH_Drawing_Typeface object, which defines the default font.
void OH_Drawing_TypefaceDestroy (OH_Drawing_Typeface *) Destroys an OH_Drawing_Typeface object and reclaims the memory occupied by the object.
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.

Type Description

OH_Drawing_Bitmap

typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap

Description

Defines a bitmap, which is a memory area that contains the pixel data of a shape.

Since: 8

OH_Drawing_Brush

typedef struct OH_Drawing_Brush OH_Drawing_Brush

Description

Defines a brush, which is used to describe the style and color to fill in a shape.

Since: 8

OH_Drawing_Canvas

typedef struct OH_Drawing_Canvas OH_Drawing_Canvas

Description

Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen.

Since: 8

OH_Drawing_ColorFilter

typedef struct OH_Drawing_ColorFilter OH_Drawing_ColorFilter

Description

Defines a color filter, which is used to convert a color into a new one.

Since: 11

OH_Drawing_Filter

typedef struct OH_Drawing_Filter OH_Drawing_Filter

Description

Defines a filter, which consists of a color filter and mask filter.

Since: 11

OH_Drawing_Font

typedef struct OH_Drawing_Font OH_Drawing_Font

Description

Defines a font.

Since: 11

OH_Drawing_FontCollection

typedef struct OH_Drawing_FontCollection OH_Drawing_FontCollection

Description

Defines a font collection, which is used to load fonts.

Since: 8

OH_Drawing_MaskFilter

typedef struct OH_Drawing_MaskFilter OH_Drawing_MaskFilter

Description

Defines a mask filter, which is used to convert a mask into a new one.

Since: 11

OH_Drawing_Matrix

typedef struct OH_Drawing_MatrixOH_Drawing_Matrix

Description

Defines a matrix, which is used to describe coordinate transformation.

Since: 11

OH_Drawing_Path

typedef struct OH_Drawing_PathOH_Drawing_Path

Description

Defines a path, which is used to customize various shapes.

Since: 8

OH_Drawing_Pen

typedef struct OH_Drawing_Pen OH_Drawing_Pen

Description

Defines a pen, which is used to describe the style and color to outline a shape.

Since: 8

OH_Drawing_Point

typedef struct OH_Drawing_Point OH_Drawing_Point

Description

Defines a coordinate point.

Since: 11

OH_Drawing_PositionAndAffinity

typedef struct OH_Drawing_PositionAndAffinity OH_Drawing_PositionAndAffinity

Description

Used to receive the position and affinity of the graph.

Since: 11

OH_Drawing_Range

typedef struct OH_Drawing_Range OH_Drawing_Range

Description

Defines a range, which is used to receive the start position and end position of the font.

Since: 11

OH_Drawing_Rect

typedef struct OH_Drawing_Rect OH_Drawing_Rect

Description

Defines a rectangle.

Since: 11

OH_Drawing_RoundRect

typedef struct OH_Drawing_RoundRect OH_Drawing_RoundRect

Description

Defines a rounded rectangle.

Since: 11

OH_Drawing_ShaderEffect

typedef struct OH_Drawing_ShaderEffectOH_Drawing_ShaderEffect

Description

Defines a shader effect, which is used to describe the source color of the drawn content.

Since: 11

OH_Drawing_TextBlob

typedef struct OH_Drawing_TextBlobOH_Drawing_TextBlob

Description

Defines a text blob, which is an immutable container that holds multiple texts. Each text line consists of a glyph and position.

Since: 11

OH_Drawing_TextBlobBuilder

typedef struct OH_Drawing_TextBlobBuilderOH_Drawing_TextBlobBuilder

Description

Defines a text blob builder, which is used to build a text blob.

Since: 11

OH_Drawing_TextBox

typedef struct OH_Drawing_TextBoxOH_Drawing_TextBox

Description

Defines a text box, which is used to receive the rectangle size, direction, and quantity.

Since: 11

OH_Drawing_TextStyle

typedef struct OH_Drawing_TextStyleOH_Drawing_TextStyle

Description

Used to manage text colors and decorations.

Since: 8

OH_Drawing_Typeface

typedef struct OH_Drawing_TypefaceOH_Drawing_Typeface

Description

Defines a typeface.

Since: 11

OH_Drawing_Typography

typedef struct OH_Drawing_TypographyOH_Drawing_Typography

Description

Used to manage the typography layout and display.

Since: 8

OH_Drawing_TypographyCreate

typedef struct OH_Drawing_TypographyCreateOH_Drawing_TypographyCreate

Description

Used to create an OH_Drawing_Typography.

Since: 8

OH_Drawing_TypographyStyle

typedef struct OH_Drawing_TypographyStyleOH_Drawing_TypographyStyle

Description

Defines the typography style, such as the text direction.

Since: 8

Enum Description

OH_Drawing_AlphaFormat

enum OH_Drawing_AlphaFormat

Description

Enumerates the alpha formats of bitmap pixels.

Since: 8

Value Description
ALPHA_FORMAT_UNKNOWN Unknown format.
ALPHA_FORMAT_OPAQUE The bitmap does not have the alpha component.
ALPHA_FORMAT_PREMUL The color component of each pixel is premultiplied by the alpha component.
ALPHA_FORMAT_UNPREMUL The color component of each pixel is not premultiplied by the alpha component.

OH_Drawing_BlendMode

enum OH_Drawing_BlendMode

Description

Enumerates the blend modes. In blend mode, each operation generates a new color from two colors (source color and target color). These operations are the same on the four channels (red, green, blue, and alpha). The operations for the alpha channel are used as examples.

For brevity, the following abbreviations are used:

s: source. d: destination. sa: source alpha. da: destination alpha.

The following abbreviations are used in the calculation result:

r: The calculation methods of the four channels are the same. ra: Only the alpha channel is manipulated. rc: The other three color channels are manipulated.

Since: 11

Value Description
BLEND_MODE_CLEAR Clear mode. r = 0.
BLEND_MODE_SRC r = s (The four channels of result are equal to the four channels of source, that is, the result is equal to the source.)
BLEND_MODE_DST r = d (The four channels of result are equal to the four channels of destination, that is, the result is equal to the destination.)
BLEND_MODE_SRC_OVER r = s + (1 - sa) * d
BLEND_MODE_DST_OVER r = d + (1 - da) * s
BLEND_MODE_SRC_IN r = s * da
BLEND_MODE_DST_IN r = d * sa
BLEND_MODE_SRC_OUT r = s * (1 - da)
BLEND_MODE_DST_OUT r = d * (1 - sa)
BLEND_MODE_SRC_ATOP r = s * da + d * (1 - sa)
BLEND_MODE_DST_ATOP r = d * sa + s * (1 - da)
BLEND_MODE_XOR r = s * (1 - da) + d * (1 - sa)
BLEND_MODE_PLUS r = min(s + d, 1)
BLEND_MODE_MODULATE r = s * d
BLEND_MODE_SCREEN Screen mode. r = s + d - s * d
BLEND_MODE_OVERLAY Overlay mode.
BLEND_MODE_DARKEN Darken mode. rc = s + d - max(s * da, d * sa), ra = s + (1 - sa) * d
BLEND_MODE_LIGHTEN Lighten mode. rc = s + d - min(s * da, d * sa), ra = s + (1 - sa) * d
BLEND_MODE_COLOR_DODGE Color dodge mode.
BLEND_MODE_COLOR_BURN Color burn mode.
BLEND_MODE_HARD_LIGHT Hard light mode.
BLEND_MODE_SOFT_LIGHT Soft light mode.
BLEND_MODE_DIFFERENCE Difference mode. rc = s + d - 2 * (min(s * da, d * sa)), ra = s + (1 - sa) * d
BLEND_MODE_EXCLUSION Exclusion mode. rc = s + d - two(s * d), ra = s + (1 - sa) * d
BLEND_MODE_MULTIPLY Multiply mode. r = s * (1 - da) + d * (1 - sa) + s * d
BLEND_MODE_HUE Hue mode.
BLEND_MODE_SATURATION Saturation mode.
BLEND_MODE_COLOR Color mode.
BLEND_MODE_LUMINOSITY Luminosity mode.

OH_Drawing_BlurType

enum OH_Drawing_BlurType

Description

Enumerates the blur types.

Since: 11

Value Description
NORMAL Blurs both inside and outside the original border.
SOLID Draws solid inside the border, and blurs outside.
OUTER Draws nothing inside the border, and blurs outside.
INNER Blurs inside the border, and draws nothing outside.

OH_Drawing_BreakStrategy

enum OH_Drawing_BreakStrategy

Description

Enumerates the text break strategies.

Since: 11

Value Description
BREAK_STRATEGY_GREEDY Each line is filled as much as possible during line break.
BREAK_STRATEGY_HIGH_QUALITY Text continuity is preferentially considered during line break.
BREAK_STRATEGY_BALANCED Line breaks are performed at the word boundary.

OH_Drawing_CanvasClipOp

enum OH_Drawing_CanvasClipOp

Description

Enumerates the canvas clipping modes.

Since: 11

Value Description
DIFFERENCE Clips a specified area. That is, the difference set is obtained.
INTERSECT Retains a specified area. That is, the intersection is obtained.

OH_Drawing_ColorFormat

enum OH_Drawing_ColorFormat

Description

Enumerates the storage formats of bitmap pixels.

Since: 8

Value Description
COLOR_FORMAT_UNKNOWN Unknown format.
COLOR_FORMAT_ALPHA_8 Each pixel is represented by 8 bits, which together indicate alpha.
COLOR_FORMAT_RGB_565 Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue.
COLOR_FORMAT_ARGB_4444 Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, every 4 bits indicate alpha, red, green, and blue, respectively.
COLOR_FORMAT_RGBA_8888 Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate alpha, red, green, and blue, respectively.
COLOR_FORMAT_BGRA_8888 Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate blue, green, red, and alpha, respectively.

OH_Drawing_EllipsisModal

enum OH_Drawing_EllipsisModal

Description

Enumerates the ellipsis styles.

Since: 11

Value Description
ELLIPSIS_MODAL_HEAD Places the ellipsis in the text header.
ELLIPSIS_MODAL_MIDDLE Places the ellipsis in the middle of the text.
ELLIPSIS_MODAL_TAIL Places the ellipsis at the end of the text.

OH_Drawing_FontStyle

enum OH_Drawing_FontStyle

Description

Enumerates the font styles.

Since: 8

Value Description
FONT_STYLE_NORMAL Normal style.
FONT_STYLE_ITALIC Italic.

OH_Drawing_FontWeight

enum OH_Drawing_FontWeight

Description

Enumerates the font weights.

Since: 8

Value Description
FONT_WEIGHT_100 Thin.
FONT_WEIGHT_200 Extra-light.
FONT_WEIGHT_300 Light.
FONT_WEIGHT_400 Normal/Regular.
FONT_WEIGHT_500 Medium.
FONT_WEIGHT_600 Semi-bold.
FONT_WEIGHT_700 Bold.
FONT_WEIGHT_800 Extra-bold.
FONT_WEIGHT_900 Black.

OH_Drawing_PenLineCapStyle

enum OH_Drawing_PenLineCapStyle

Description

Enumerates the line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen.

Since: 8

Value Description
LINE_FLAT_CAP There is no cap style. Both ends of the line segment are cut off square.
LINE_SQUARE_CAP Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width.
LINE_ROUND_CAP Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment.

OH_Drawing_PenLineJoinStyle

enum OH_Drawing_PenLineJoinStyle

Description

Enumerates the line join styles of a pen. The line join style defines the shape of the joints of a polyline segment drawn by the pen.

Since: 8

Value Description
LINE_MITER_JOIN Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. In this case, you need to use the miter limit to limit the miter length.
LINE_ROUND_JOIN Round corner.
LINE_BEVEL_JOIN Beveled corner.

OH_Drawing_PlaceholderVerticalAlignment

enum OH_Drawing_PlaceholderVerticalAlignment

Description

Enumerates the vertical alignment modes of placeholders.

Since: 11

Value Description
ALIGNMENT_OFFSET_AT_BASELINE Aligned to the baseline.
ALIGNMENT_ABOVE_BASELINE Aligned above the baseline.
ALIGNMENT_BELOW_BASELINE Aligned below the baseline.
ALIGNMENT_TOP_OF_ROW_BOX Aligned to the top of the row box.
ALIGNMENT_BOTTOM_OF_ROW_BOX Aligned to the bottom of the row box.
ALIGNMENT_CENTER_OF_ROW_BOX Aligned to the center of the row box.

OH_Drawing_RectHeightStyle

enum OH_Drawing_RectHeightStyle

Description

Enumerates the rectangle height styles.

Since: 11

Value Description
RECT_HEIGHT_STYLE_TIGHT Tight style.
RECT_HEIGHT_STYLE_MAX Maximum style.
RECT_HEIGHT_STYLE_INCLUDELINESPACEMIDDLE Middle style that includes the line spacing.
RECT_HEIGHT_STYLE_INCLUDELINESPACETOP Top style that includes the line spacing.
RECT_HEIGHT_STYLE_INCLUDELINESPACEBOTTOM Bottom style that includes the line spacing.
RECT_HEIGHT_STYLE_STRUCT Structure style.

OH_Drawing_RectWidthStyle

enum OH_Drawing_RectWidthStyle

Description

Enumerates the rectangle width styles.

Since: 11

Value Description
RECT_WIDTH_STYLE_TIGHT Tight style.
RECT_WIDTH_STYLE_MAX Maximum style.

OH_Drawing_TextAlign

enum OH_Drawing_TextAlign

Description

Enumerates the text alignment modes.

Since: 8

Value Description
TEXT_ALIGN_LEFT Left-aligned.
TEXT_ALIGN_RIGHT Right-aligned.
TEXT_ALIGN_CENTER Center-aligned.
TEXT_ALIGN_JUSTIFY Justified, which means that each line (except the last line) is stretched so that every line has equal width, and the left and right margins are straight.
TEXT_ALIGN_START TEXT_ALIGN_START achieves the same effect as TEXT_ALIGN_LEFT when OH_Drawing_TextDirection is TEXT_DIRECTION_LTR; it achieves the same effect as TEXT_ALIGN_RIGHT when OH_Drawing_TextDirection is TEXT_DIRECTION_RTL.
TEXT_ALIGN_END TEXT_ALIGN_END achieves the same effect as TEXT_ALIGN_RIGHT when OH_Drawing_TextDirection is TEXT_DIRECTION_LTR; it achieves the same effect as TEXT_ALIGN_LEFT when OH_Drawing_TextDirection is TEXT_DIRECTION_RTL.

OH_Drawing_TextBaseline

enum OH_Drawing_TextBaseline

Description

Enumerates the text baselines.

Since: 8

Value Description
TEXT_BASELINE_ALPHABETIC Alphabetic, where the letters in alphabets like English sit on.
TEXT_BASELINE_IDEOGRAPHIC Ideographic. The baseline is at the bottom of the text area.

OH_Drawing_TextDecoration

enum OH_Drawing_TextDecoration

Description

Enumerates the text decorations.

Since: 8

Value Description
TEXT_DECORATION_NONE No decoration.
TEXT_DECORATION_UNDERLINE An underline is used for decoration.
TEXT_DECORATION_OVERLINE An overline is used for decoration.
TEXT_DECORATION_LINE_THROUGH A strikethrough is used for decoration.

OH_Drawing_TextDecorationStyle

enum OH_Drawing_TextDecorationStyle

Description

Enumerates the text decoration styles.

Since: 11

Value Description
TEXT_DECORATION_STYLE_SOLID Solid style.
TEXT_DECORATION_STYLE_DOUBLE Double style.
TEXT_DECORATION_STYLE_DOTTED Dotted style.
TEXT_DECORATION_STYLE_DASHED Dashed style.
TEXT_DECORATION_STYLE_WAVY Wavy style.

OH_Drawing_TextDirection

enum OH_Drawing_TextDirection

Description

Enumerates the text directions.

Since: 8

Value Description
TEXT_DIRECTION_RTL Right to left (RTL).
TEXT_DIRECTION_LTR Left to right (LTR).

OH_Drawing_TileMode

enum OH_Drawing_TileMode

Description

Enumerates the tile modes of the shader effect.

Since: 11

Value Description
CLAMP Replicates the edge color if the shader effect draws outside of its original boundary.
REPEAT Repeats the shader effect's image in both horizontal and vertical directions.
MIRROR Repeats the shader effect's image in both horizontal and vertical directions, alternating mirror images.
DECAL Renders the shader effect's image only within the original boundary, and returns transparent black elsewhere.

OH_Drawing_WordBreakType

enum OH_Drawing_WordBreakType

Description

Enumerates the word break types.

Since: 11

Value Description
WORD_BREAK_TYPE_NORMAL Normal mode.
WORD_BREAK_TYPE_BREAK_ALL Breaks the words at any character to prevent overflow.
WORD_BREAK_TYPE_BREAK_WORD Breaks the words at arbitrary points to prevent overflow.

Function Description

OH_Drawing_BitmapBuild()

void OH_Drawing_BitmapBuild (OH_Drawing_Bitmap * , const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat *  )

Description

Initializes the width and height of a bitmap and sets the pixel format for the bitmap.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.
width Width of the bitmap to be initialized.
height Height of the bitmap to be initialized.
OH_Drawing_BitmapFormat Pointer to the pixel format of the bitmap to be initialized, including the pixel color type and alpha type.

OH_Drawing_BitmapCreate()

OH_Drawing_Bitmap* OH_Drawing_BitmapCreate (void )

Description

Creates an OH_Drawing_Bitmap object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_Bitmap object created.

OH_Drawing_BitmapDestroy()

void OH_Drawing_BitmapDestroy (OH_Drawing_Bitmap * )

Description

Destroys an OH_Drawing_Bitmap object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.

OH_Drawing_BitmapGetHeight()

uint32_t OH_Drawing_BitmapGetHeight (OH_Drawing_Bitmap * )

Description

Obtains the height of a bitmap.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.

Returns

Returns the height.

OH_Drawing_BitmapGetPixels()

void* OH_Drawing_BitmapGetPixels (OH_Drawing_Bitmap * )

Description

Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.

Returns

Returns the pixel address.

OH_Drawing_BitmapGetWidth()

uint32_t OH_Drawing_BitmapGetWidth (OH_Drawing_Bitmap * )

Description

Obtains the width of a bitmap.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.

Returns

Returns the width.

OH_Drawing_BrushCreate()

OH_Drawing_Brush* OH_Drawing_BrushCreate (void )

Description

Creates an OH_Drawing_Brush object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_Brush object created.

OH_Drawing_BrushDestroy()

void OH_Drawing_BrushDestroy (OH_Drawing_Brush * )

Description

Destroys an OH_Drawing_Brush object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.

OH_Drawing_BrushGetAlpha()

uint8_t OH_Drawing_BrushGetAlpha (const OH_Drawing_Brush * )

Description

Obtains the alpha value of a brush. This value is used by the alpha channel when the brush fills in a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.

Returns

Returns an 8-bit variable that describes the alpha value.

OH_Drawing_BrushGetColor()

uint32_t OH_Drawing_BrushGetColor (const OH_Drawing_Brush * )

Description

Obtains the color of a brush. The color is used by the brush to fill in a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.

Returns

Returns a 32-bit (ARGB) variable that describes the color.

OH_Drawing_BrushIsAntiAlias()

bool OH_Drawing_BrushIsAntiAlias (const OH_Drawing_Brush * )

Description

Checks whether anti-aliasing is enabled for a brush. Anti-aliasing makes the pixels around the shape edges semi-transparent.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.

Returns

Returns true if anti-aliasing is enabled; returns false otherwise.

OH_Drawing_BrushSetAlpha()

void OH_Drawing_BrushSetAlpha (OH_Drawing_Brush * , uint8_t alpha )

Description

Sets the alpha value for a brush. This value is used by the alpha channel when the brush fills in a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.
alpha Alpha value, which is an 8-bit variable.

OH_Drawing_BrushSetAntiAlias()

void OH_Drawing_BrushSetAntiAlias (OH_Drawing_Brush * , bool  )

Description

Enables or disables anti-aliasing for a brush. Anti-aliasing makes the pixels around the shape edges semi-transparent.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.
bool Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite.

OH_Drawing_BrushSetColor()

void OH_Drawing_BrushSetColor (OH_Drawing_Brush * , uint32_t color )

Description

Sets the color for a brush. The color is used by the brush to fill in a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.
color Color, which is a 32-bit (ARGB) variable.

OH_Drawing_BrushSetFilter()

void OH_Drawing_BrushSetFilter (OH_Drawing_Brush * , OH_Drawing_Filter *  )

Description

Sets a filter for a brush. The filter is a container that holds a mask filter and color filter.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.
OH_Drawing_Filter Pointer to an OH_Drawing_Filter object.

OH_Drawing_BrushSetShaderEffect()

void OH_Drawing_BrushSetShaderEffect (OH_Drawing_Brush * , OH_Drawing_ShaderEffect *  )

Description

Sets the shader effect for a brush.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.
OH_Drawing_ShaderEffect Pointer to an OH_Drawing_ShaderEffect object.

OH_Drawing_CanvasAttachBrush()

void OH_Drawing_CanvasAttachBrush (OH_Drawing_Canvas * , const OH_Drawing_Brush *  )

Description

Attaches a brush to a canvas so that the canvas can use the style and color of the brush to fill in a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Brush Pointer to an OH_Drawing_Brush object.

OH_Drawing_CanvasAttachPen()

void OH_Drawing_CanvasAttachPen (OH_Drawing_Canvas * , const OH_Drawing_Pen *  )

Description

Attaches a pen to a canvas so that the canvas can use the style and color of the pen to outline a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

OH_Drawing_CanvasBind()

void OH_Drawing_CanvasBind (OH_Drawing_Canvas * , OH_Drawing_Bitmap *  )

Description

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.)

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.

OH_Drawing_CanvasClear()

void OH_Drawing_CanvasClear (OH_Drawing_Canvas * , uint32_t color )

Description

Clears a canvas by using a given color.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
color Color, which is a 32-bit (ARGB) variable.

OH_Drawing_CanvasClipPath()

void OH_Drawing_CanvasClipPath (OH_Drawing_Canvas * , const OH_Drawing_Path * , OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias )

Description

Clips a path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
clipOp Clip mode. For details about the available options, see OH_Drawing_CanvasClipOp.
doAntiAlias Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite.

OH_Drawing_CanvasClipRect()

void OH_Drawing_CanvasClipRect (OH_Drawing_Canvas * , const OH_Drawing_Rect * , OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias )

Description

Clips a rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.
clipOp Clip mode. For details about the available options, see OH_Drawing_CanvasClipOp.
doAntiAlias Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite.

OH_Drawing_CanvasCreate()

OH_Drawing_Canvas* OH_Drawing_CanvasCreate (void )

Description

Creates an OH_Drawing_Canvas object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_Canvas object created.

OH_Drawing_CanvasDestroy()

void OH_Drawing_CanvasDestroy (OH_Drawing_Canvas * )

Description

Destroys an OH_Drawing_Canvas object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

OH_Drawing_CanvasDetachBrush()

void OH_Drawing_CanvasDetachBrush (OH_Drawing_Canvas * )

Description

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.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

OH_Drawing_CanvasDetachPen()

void OH_Drawing_CanvasDetachPen (OH_Drawing_Canvas * )

Description

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.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

OH_Drawing_CanvasDrawArc()

void OH_Drawing_CanvasDrawArc (OH_Drawing_Canvas * , const OH_Drawing_Rect * , float startAngle, float sweepAngle )

Description

Draws an arc.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.
startAngle Start angle of the arc.
sweepAngle Sweep angle of the arc.

OH_Drawing_CanvasDrawBitmap()

void OH_Drawing_CanvasDrawBitmap (OH_Drawing_Canvas * , const OH_Drawing_Bitmap * , float left, float top )

Description

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).

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Bitmap Pointer to an OH_Drawing_Bitmap object.
left X coordinate of the upper left corner of the bitmap.
top Y coordinate of the upper left corner of the bitmap.

OH_Drawing_CanvasDrawCircle()

void OH_Drawing_CanvasDrawCircle (OH_Drawing_Canvas * , const OH_Drawing_Point * , float radius )

Description

Draws a circle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Point Pointer to an OH_Drawing_Point object, which indicates the center of the circle.
radius Radius of the circle.

OH_Drawing_CanvasDrawLine()

void OH_Drawing_CanvasDrawLine (OH_Drawing_Canvas * , float x1, float y1, float x2, float y2 )

Description

Draws a line segment.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
x1 X coordinate of the start point of the line segment.
y1 Y coordinate of the start point of the line segment.
x2 X coordinate of the end point of the line segment.
y2 Y coordinate of the end point of the line segment.

OH_Drawing_CanvasDrawOval()

void OH_Drawing_CanvasDrawOval (OH_Drawing_Canvas * , const OH_Drawing_Rect *  )

Description

Draws an oval.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.

OH_Drawing_CanvasDrawPath()

void OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas * , const OH_Drawing_Path *  )

Description

Draws a path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Path Pointer to an OH_Drawing_Path object.

OH_Drawing_CanvasDrawRect()

void OH_Drawing_CanvasDrawRect (OH_Drawing_Canvas * , const OH_Drawing_Rect *  )

Description

Draws a rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.

OH_Drawing_CanvasDrawRoundRect()

void OH_Drawing_CanvasDrawRoundRect (OH_Drawing_Canvas * , const OH_Drawing_RoundRect *  )

Description

Draws a rounded rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_RoundRect Pointer to an OH_Drawing_RoundRect object.

OH_Drawing_CanvasDrawTextBlob()

void OH_Drawing_CanvasDrawTextBlob (OH_Drawing_Canvas * , const OH_Drawing_TextBlob * , float x, float y )

Description

Draws a text blob.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
OH_Drawing_TextBlob Pointer to an OH_Drawing_TextBlob object.
x X coordinate of the lower left corner of the text blob.
y Y coordinate of the lower left corner of the text blob.

OH_Drawing_CanvasGetSaveCount()

uint32_t OH_Drawing_CanvasGetSaveCount (OH_Drawing_Canvas * )

Description

Obtains the number of canvas statuses (canvas matrices) saved in the stack.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

Returns

Returns a 32-bit value that describes the number of canvas statuses (canvas matrices).

OH_Drawing_CanvasRestore()

void OH_Drawing_CanvasRestore (OH_Drawing_Canvas * )

Description

Restores the canvas status (canvas matrix) saved on the top of the stack.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

OH_Drawing_CanvasRestoreToCount()

void OH_Drawing_CanvasRestoreToCount (OH_Drawing_Canvas * , uint32_t saveCount )

Description

Restores to a given number of canvas statuses (canvas matrices).

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
saveCount Number of canvas statuses (canvas matrices).

OH_Drawing_CanvasRotate()

void OH_Drawing_CanvasRotate (OH_Drawing_Canvas * , float degrees, float px, float py )

Description

Rotates a canvas by a given angle. A positive number indicates clockwise rotation, and a negative number indicates clockwise rotation.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
degrees Angle to rotate.
px X coordinate of the rotation center.
py Y coordinate of the rotation center.

OH_Drawing_CanvasSave()

void OH_Drawing_CanvasSave (OH_Drawing_Canvas * )

Description

Saves the current canvas status (canvas matrix) to the top of the stack.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.

OH_Drawing_CanvasScale()

void OH_Drawing_CanvasScale (OH_Drawing_Canvas * , float sx, float sy )

Description

Scales a canvas.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
sx Horizontal scale factor.
sy Vertical scale factor.

OH_Drawing_CanvasTranslate()

void OH_Drawing_CanvasTranslate (OH_Drawing_Canvas * , float dx, float dy )

Description

Translates a canvas by a given distance.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object.
dx Distance to translate in the horizontal direction.
dy Distance to translate in the vertical direction.

OH_Drawing_ColorFilterCreateBlendMode()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateBlendMode (uint32_t color, OH_Drawing_BlendMode  )

Description

Creates an OH_Drawing_ColorFilter object with a given blend mode.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
color Color, which is a 32-bit (ARGB) variable.
OH_Drawing_BlendMode Blend mode. For details about the available options, see OH_Drawing_BlendMode.

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterCreateCompose()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateCompose (OH_Drawing_ColorFilter * colorFilter1, OH_Drawing_ColorFilter * colorFilter2 )

Description

Creates an OH_Drawing_ColorFilter object by combining another two color filters.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_ColorFilter Pointer to the first color filter.
OH_Drawing_ColorFilter Pointer to the second color filter.

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterCreateLinearToSrgbGamma()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateLinearToSrgbGamma (void )

Description

Creates an OH_Drawing_ColorFilter object that applies the sRGB gamma curve to the RGB channels.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterCreateLuma()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateLuma (void )

Description

Creates an OH_Drawing_ColorFilter object that multiplies the passed-in luma into the alpha channel and sets the RGB channels to zero.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterCreateMatrix()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateMatrix (const float matrix[20])

Description

Creates an OH_Drawing_ColorFilter object with a given 5x4 color matrix.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
matrix Matrix, which is represented by a floating-point array with a length of 20.

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterCreateSrgbGammaToLinear()

OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateSrgbGammaToLinear (void )

Description

Creates an OH_Drawing_ColorFilter object that applies the RGB channels to the sRGB gamma curve.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_ColorFilter object created.

OH_Drawing_ColorFilterDestroy()

void OH_Drawing_ColorFilterDestroy (OH_Drawing_ColorFilter * )

Description

Destroys an OH_Drawing_ColorFilter object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_ColorFilter Pointer to an OH_Drawing_ColorFilter object.

OH_Drawing_ColorSetArgb()

uint32_t OH_Drawing_ColorSetArgb (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue )

Description

Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
alpha Alpha, which is a variable ranging from 0x00 to 0xFF.
red Read, which is a variable ranging from 0x00 to 0xFF.
green Green, which is a variable ranging from 0x00 to 0xFF.
blue Blue, which is a variable ranging from 0x00 to 0xFF.

Returns

Returns a 32-bit (ARGB) variable that describes the color.

OH_Drawing_CreateFontCollection()

OH_Drawing_FontCollection* OH_Drawing_CreateFontCollection (void )

Description

Creates an OH_Drawing_FontCollection object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_FontCollection object created.

OH_Drawing_CreateTextStyle()

OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle (void )

Description

Creates an OH_Drawing_TextStyle object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_TextStyle object created.

OH_Drawing_CreateTypography()

OH_Drawing_Typography* OH_Drawing_CreateTypography (OH_Drawing_TypographyCreate * )

Description

Creates an OH_Drawing_Typography object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.

Returns

Returns the pointer to the OH_Drawing_Typography object created.

OH_Drawing_CreateTypographyHandler()

OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler (OH_Drawing_TypographyStyle * , OH_Drawing_FontCollection *  )

Description

Creates an OH_Drawing_TypographyCreate object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
OH_Drawing_FontCollection Pointer to an OH_Drawing_FontCollection object, which is obtained by OH_Drawing_CreateFontCollection.

Returns

Returns the pointer to the OH_Drawing_TypographyCreate object created.

OH_Drawing_CreateTypographyStyle()

OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle (void )

Description

Creates an OH_Drawing_TypographyStyle object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_TypographyStyle object created.

OH_Drawing_DestroyFontCollection()

void OH_Drawing_DestroyFontCollection (OH_Drawing_FontCollection * )

Description

Destroys an OH_Drawing_FontCollection object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_FontCollection Pointer to an OH_Drawing_FontCollection object.

OH_Drawing_DestroyTextStyle()

void OH_Drawing_DestroyTextStyle (OH_Drawing_TextStyle * )

Description

Destroys an OH_Drawing_TextStyle object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.

OH_Drawing_DestroyTypography()

void OH_Drawing_DestroyTypography (OH_Drawing_Typography * )

Description

Destroys an OH_Drawing_Typography object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

OH_Drawing_DestroyTypographyHandler()

void OH_Drawing_DestroyTypographyHandler (OH_Drawing_TypographyCreate * )

Description

Destroys an OH_Drawing_TypographyCreate object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.

OH_Drawing_DestroyTypographyStyle()

void OH_Drawing_DestroyTypographyStyle (OH_Drawing_TypographyStyle * )

Description

Destroys an OH_Drawing_TypographyStyle object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.

OH_Drawing_FilterCreate()

OH_Drawing_Filter* OH_Drawing_FilterCreate (void )

Description

Creates an OH_Drawing_Filter object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_Filter object created.

OH_Drawing_FilterDestroy()

void OH_Drawing_FilterDestroy (OH_Drawing_Filter * )

Description

Destroys an OH_Drawing_Filter object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Filter Pointer to an OH_Drawing_Filter object.

OH_Drawing_FilterSetColorFilter()

void OH_Drawing_FilterSetColorFilter (OH_Drawing_Filter * , OH_Drawing_ColorFilter *  )

Description

Sets an OH_Drawing_ColorFilter object for an OH_Drawing_Filter object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Filter Pointer to an OH_Drawing_Filter object.
OH_Drawing_ColorFilter Pointer to an OH_Drawing_ColorFilter object.

OH_Drawing_FilterSetMaskFilter()

void OH_Drawing_FilterSetMaskFilter (OH_Drawing_Filter * , OH_Drawing_MaskFilter *  )

Description

Sets an OH_Drawing_MaskFilter object for an OH_Drawing_Filter object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Filter Pointer to an OH_Drawing_Filter object.
OH_Drawing_MaskFilter Pointer to an OH_Drawing_MaskFilter object.

OH_Drawing_FontCreate()

OH_Drawing_Font* OH_Drawing_FontCreate (void )

Description

Creates an OH_Drawing_Font object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_Font object created.

OH_Drawing_FontDestroy()

void OH_Drawing_FontDestroy (OH_Drawing_Font * )

Description

Destroys an OH_Drawing_Font object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.

OH_Drawing_FontSetFakeBoldText()

void OH_Drawing_FontSetFakeBoldText (OH_Drawing_Font * , bool isFakeBoldText )

Description

Sets fake bold for a font by increasing the stroke width.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
isFakeBoldText Whether to set fake bold. The value true means to set fake bold, and false means the opposite.

OH_Drawing_FontSetLinearText()

void OH_Drawing_FontSetLinearText (OH_Drawing_Font * , bool isLinearText )

Description

Sets linear scaling for a font.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
isLinearText Whether to set linear scaling. The value true means to set linear scaling, and false means the opposite.

OH_Drawing_FontSetTextSize()

void OH_Drawing_FontSetTextSize (OH_Drawing_Font * , float textSize )

Description

Sets the font size.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
textSize Font size.

OH_Drawing_FontSetTextSkewX()

void OH_Drawing_FontSetTextSkewX (OH_Drawing_Font * , float skewX )

Description

Sets a horizontal skew factor for a font.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
skewX Skew of the X axis relative to the Y axis.

OH_Drawing_FontSetTypeface()

void OH_Drawing_FontSetTypeface (OH_Drawing_Font * , OH_Drawing_Typeface *  )

Description

Sets the typeface for a font.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
OH_Drawing_Typeface Pointer to an OH_Drawing_Typeface object.

OH_Drawing_GetAffinityFromPositionAndAffinity()

int OH_Drawing_GetAffinityFromPositionAndAffinity (OH_Drawing_PositionAndAffinity * )

Description

Obtains the affinity attribute of an OH_Drawing_PositionAndAffinity object. The affinity determines whether the font is close to the front text or rear text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_PositionAndAffinity Pointer to an OH_Drawing_PositionAndAffinity object, which is obtained by OH_Drawing_TypographyGetGlyphPositionAtCoordinate or OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster.

Returns

Returns the affinity attribute.

OH_Drawing_GetBottomFromTextBox()

float OH_Drawing_GetBottomFromTextBox (OH_Drawing_TextBox * , int  )

Description

Obtains the bottom position of a text box.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.
int Index of the text box.

Returns

Returns the bottom position.

OH_Drawing_GetEndFromRange()

size_t OH_Drawing_GetEndFromRange (OH_Drawing_Range * )

Description

Obtains the end position of an OH_Drawing_Range object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Range Pointer to an OH_Drawing_Range object, which is obtained by OH_Drawing_TypographyGetWordBoundary.

Returns

Returns the end position.

OH_Drawing_GetLeftFromTextBox()

float OH_Drawing_GetLeftFromTextBox (OH_Drawing_TextBox * , int  )

Description

Obtains the left position of a text box.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.
int Index of the text box.

Returns

Returns the left position.

OH_Drawing_GetPositionFromPositionAndAffinity()

size_t OH_Drawing_GetPositionFromPositionAndAffinity (OH_Drawing_PositionAndAffinity * )

Description

Obtains the position attribute of an OH_Drawing_PositionAndAffinity object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_PositionAndAffinity Pointer to an OH_Drawing_PositionAndAffinity object, which is obtained by OH_Drawing_TypographyGetGlyphPositionAtCoordinate or OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster.

Returns

Returns the position attribute.

OH_Drawing_GetRightFromTextBox()

float OH_Drawing_GetRightFromTextBox (OH_Drawing_TextBox * , int  )

Description

Obtains the right position of a text box.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.
int Index of the text box.

Returns

Returns the right position.

OH_Drawing_GetSizeOfTextBox()

size_t OH_Drawing_GetSizeOfTextBox (OH_Drawing_TextBox * )

Description

Obtains the number of text boxes.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.

Returns

Returns the number of text boxes.

OH_Drawing_GetStartFromRange()

size_t OH_Drawing_GetStartFromRange (OH_Drawing_Range * )

Description

Obtains the start position of an OH_Drawing_Range object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Range Pointer to an OH_Drawing_Range object, which is obtained by OH_Drawing_TypographyGetWordBoundary.

Returns

Returns the start position.

OH_Drawing_GetTextDirectionFromTextBox()

int OH_Drawing_GetTextDirectionFromTextBox (OH_Drawing_TextBox * , int  )

Description

Obtains the text direction of a text box.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.
int Index of the text box.

Returns

Returns the text direction.

OH_Drawing_GetTopFromTextBox()

float OH_Drawing_GetTopFromTextBox (OH_Drawing_TextBox * , int  )

Description

Obtains the top position of a text box.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBox Pointer to an OH_Drawing_TextBox object, which is obtained by OH_Drawing_TypographyGetRectsForRange or OH_Drawing_TypographyGetRectsForPlaceholders.
int Index of the text box.

Returns

Returns the top position.

OH_Drawing_MaskFilterCreateBlur()

OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateBlur (OH_Drawing_BlurType blurType, float sigma, bool respectCTM )

Description

Creates an OH_Drawing_MaskFilter object with a given blur type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
blurType Blur type.
sigma Standard deviation of the Gaussian blur to apply. The value must be greater than 0.
respectCTM Whether the blur's sigma is modified by the CTM. The default value is true.

Returns

Returns the pointer to the OH_Drawing_MaskFilter object created.

OH_Drawing_MaskFilterDestroy()

void OH_Drawing_MaskFilterDestroy (OH_Drawing_MaskFilter * )

Description

Destroys an OH_Drawing_MaskFilter object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_MaskFilter Pointer to an OH_Drawing_MaskFilter object.

OH_Drawing_MatrixCreate()

OH_Drawing_Matrix* OH_Drawing_MatrixCreate (void )

Description

Creates an OH_Drawing_Matrix object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_Matrix object created.

OH_Drawing_MatrixDestroy()

void OH_Drawing_MatrixDestroy (OH_Drawing_Matrix * )

Description

Destroys an OH_Drawing_Matrix object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Matrix Pointer to an OH_Drawing_Font object.

OH_Drawing_MatrixSetMatrix()

void OH_Drawing_MatrixSetMatrix (OH_Drawing_Matrix * , float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0, float persp1, float persp2 )

Description

Sets matrix parameters for an OH_Drawing_Matrix object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Matrix Pointer to an OH_Drawing_Matrix object.
scaleX Horizontal scale factor.
skewX Horizontal skew coefficient.
transX Horizontal translation coefficient.
skewY Vertical skew coefficient.
scaleY Vertical scale factor.
transY Vertical translation coefficient.
persp0 Perspective coefficient of the X axis.
persp1 Perspective coefficient of the Y axis.
persp2 Perspective scale coefficient.

OH_Drawing_PathArcTo()

void OH_Drawing_PathArcTo (OH_Drawing_Path * , float x1, float y1, float x2, float y2, float startDeg, float sweepDeg )

Description

Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
x1 X coordinate of the upper left corner of the rectangle.
y1 Y coordinate of the upper left corner of the rectangle.
x2 X coordinate of the lower right corner of the rectangle.
y2 Y coordinate of the lower right corner of the rectangle.
startDeg Start angle.
sweepDeg Sweep degree.

OH_Drawing_PathClose()

void OH_Drawing_PathClose (OH_Drawing_Path * )

Description

Closes a path by drawing a line segment from the current point to the start point of the path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.

OH_Drawing_PathCreate()

OH_Drawing_Path* OH_Drawing_PathCreate (void )

Description

Creates an OH_Drawing_Path object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_Path object created.

OH_Drawing_PathCubicTo()

void OH_Drawing_PathCubicTo (OH_Drawing_Path * , float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY )

Description

Draws a cubic Bezier curve from the last point of a path to the target point.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
ctrlX1 X coordinate of the first control point.
ctrlY1 Y coordinate of the first control point.
ctrlX2 X coordinate of the second control point.
ctrlY2 Y coordinate of the second control point.
endX X coordinate of the target point.
endY Y coordinate of the target point.

OH_Drawing_PathDestroy()

void OH_Drawing_PathDestroy (OH_Drawing_Path * )

Description

Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.

OH_Drawing_PathLineTo()

void OH_Drawing_PathLineTo (OH_Drawing_Path * , float x, float y )

Description

Draws a line segment from the last point of a path to the target point.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
x X coordinate of the target point.
y Y coordinate of the target point.

OH_Drawing_PathMoveTo()

void OH_Drawing_PathMoveTo (OH_Drawing_Path * , float x, float y )

Description

Sets the start point of a path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
x X coordinate of the start point.
y Y coordinate of the start point.

OH_Drawing_PathQuadTo()

void OH_Drawing_PathQuadTo (OH_Drawing_Path * , float ctrlX, float ctrlY, float endX, float endY )

Description

Draws a quadratic Bezier curve from the last point of a path to the target point.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.
ctrlX X coordinate of the control point.
ctrlY Y coordinate of the control point.
endX X coordinate of the target point.
endY Y coordinate of the target point.

OH_Drawing_PathReset()

void OH_Drawing_PathReset (OH_Drawing_Path * )

Description

Resets path data.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Path Pointer to an OH_Drawing_Path object.

OH_Drawing_PenCreate()

OH_Drawing_Pen* OH_Drawing_PenCreate (void )

Description

Creates an OH_Drawing_Pen object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

Returns the pointer to the OH_Drawing_Pen object created.

OH_Drawing_PenDestroy()

void OH_Drawing_PenDestroy (OH_Drawing_Pen * )

Description

Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

OH_Drawing_PenGetAlpha()

uint8_t OH_Drawing_PenGetAlpha (const OH_Drawing_Pen * )

Description

Obtains the alpha value of a pen. This value is used by the alpha channel when the pen outlines a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns an 8-bit variable that describes the alpha value.

OH_Drawing_PenGetCap()

OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap (const OH_Drawing_Pen * )

Description

Obtains the line cap style of a pen.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns the line cap style.

OH_Drawing_PenGetColor()

uint32_t OH_Drawing_PenGetColor (const OH_Drawing_Pen * )

Description

Obtains the color of a pen. The color is used by the pen to outline a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns a 32-bit (ARGB) variable that describes the color.

OH_Drawing_PenGetJoin()

OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin (const OH_Drawing_Pen * )

Description

Obtains the line join style of a pen.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns the line join style.

OH_Drawing_PenGetMiterLimit()

float OH_Drawing_PenGetMiterLimit (const OH_Drawing_Pen * )

Description

Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns the miter limit.

OH_Drawing_PenGetWidth()

float OH_Drawing_PenGetWidth (const OH_Drawing_Pen * )

Description

Obtains the thickness of a pen. This thickness determines the width of the outline of a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns the thickness.

OH_Drawing_PenIsAntiAlias()

bool OH_Drawing_PenIsAntiAlias (const OH_Drawing_Pen * )

Description

Checks whether anti-aliasing is enabled for a pen. Anti-aliasing makes the pixels around the shape edges semi-transparent.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.

Returns

Returns true if anti-aliasing is enabled; returns false otherwise.

OH_Drawing_PenSetAlpha()

void OH_Drawing_PenSetAlpha (OH_Drawing_Pen * , uint8_t alpha )

Description

Sets the alpha value for a pen. This value is used by the alpha channel when the pen outlines a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
alpha Alpha value, which is an 8-bit variable.

OH_Drawing_PenSetAntiAlias()

void OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen * , bool  )

Description

Enables or disables anti-aliasing for a pen. Anti-aliasing makes the pixels around the shape edges semi-transparent.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
bool Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite.

OH_Drawing_PenSetCap()

void OH_Drawing_PenSetCap (OH_Drawing_Pen * , OH_Drawing_PenLineCapStyle  )

Description

Sets the line cap style for a pen.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
OH_Drawing_PenLineCapStyle Line cap style, which is a variable.

OH_Drawing_PenSetColor()

void OH_Drawing_PenSetColor (OH_Drawing_Pen * , uint32_t color )

Description

Sets the color for a pen. The color is used by the pen to outline a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
color Color, which is a 32-bit (ARGB) variable.

OH_Drawing_PenSetJoin()

void OH_Drawing_PenSetJoin (OH_Drawing_Pen * , OH_Drawing_PenLineJoinStyle  )

Description

Sets the line join style for a pen.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
OH_Drawing_PenLineJoinStyle Line join style, which is a variable.

OH_Drawing_PenSetMiterLimit()

void OH_Drawing_PenSetMiterLimit (OH_Drawing_Pen * , float miter )

Description

Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
miter Stroke miter limit, which is a variable.

OH_Drawing_PenSetWidth()

void OH_Drawing_PenSetWidth (OH_Drawing_Pen * , float width )

Description

Sets the thickness for a pen. This thickness determines the width of the outline of a shape.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Pen Pointer to an OH_Drawing_Pen object.
width Thickness, which is a variable.

OH_Drawing_PointCreate()

OH_Drawing_Point* OH_Drawing_PointCreate (float x, float y )

Description

Creates an OH_Drawing_Point object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
x X coordinate of the point.
y Y coordinate of the point.

Returns

Returns the pointer to the OH_Drawing_Point object created.

OH_Drawing_PointDestroy()

void OH_Drawing_PointDestroy (OH_Drawing_Point * )

Description

Destroys an OH_Drawing_Point object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Point Pointer to an OH_Drawing_Point object.

OH_Drawing_RectCreate()

OH_Drawing_Rect* OH_Drawing_RectCreate (float left, float top, float right, float bottom )

Description

Creates an OH_Drawing_Rect object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
left X coordinate of the upper left corner of the rectangle.
top Y coordinate of the upper left corner of the rectangle.
right X coordinate of the lower right corner of the rectangle.
bottom Y coordinate of the lower right corner of the rectangle.

Returns

Returns the pointer to the OH_Drawing_Rect object created.

OH_Drawing_RectDestroy()

void OH_Drawing_RectDestroy (OH_Drawing_Rect * )

Description

Destroys an OH_Drawing_Rect object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.

OH_Drawing_RoundRectCreate()

OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate (const OH_Drawing_Rect * , float xRad, float yRad )

Description

Creates an OH_Drawing_RoundRect object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Rect Pointer to an OH_Drawing_Rect object.
xRad Radius of the rounded corner on the X axis.
yRad Radius of the rounded corner on the Y axis.

Returns

Returns the pointer to the OH_Drawing_RoundRect object created.

OH_Drawing_RoundRectDestroy()

void OH_Drawing_RoundRectDestroy (OH_Drawing_RoundRect * )

Description

Destroys an OH_Drawing_RoundRect object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_RoundRect Pointer to an OH_Drawing_RoundRect object.

OH_Drawing_SetTextStyleBaseLine()

void OH_Drawing_SetTextStyleBaseLine (OH_Drawing_TextStyle * , int  )

Description

Sets the text baseline.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Text baseline. For details about the available options, see OH_Drawing_TextBaseline.

OH_Drawing_SetTextStyleColor()

void OH_Drawing_SetTextStyleColor (OH_Drawing_TextStyle * , uint32_t  )

Description

Sets the text color.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
uint32_t Color.

OH_Drawing_SetTextStyleDecoration()

void OH_Drawing_SetTextStyleDecoration (OH_Drawing_TextStyle * , int  )

Description

Sets the text decoration.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Text decoration. For details about the available options, see OH_Drawing_TextDecoration.

OH_Drawing_SetTextStyleDecorationColor()

void OH_Drawing_SetTextStyleDecorationColor (OH_Drawing_TextStyle * , uint32_t  )

Description

Sets the color for the text decoration.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
uint32_t Color.

OH_Drawing_SetTextStyleDecorationStyle()

void OH_Drawing_SetTextStyleDecorationStyle (OH_Drawing_TextStyle * , int  )

Description

Sets the text decoration style.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Text decoration style. For details about the available options, see OH_Drawing_TextDecorationStyle.

OH_Drawing_SetTextStyleDecorationThicknessScale()

void OH_Drawing_SetTextStyleDecorationThicknessScale (OH_Drawing_TextStyle * , double  )

Description

Sets the thickness scale factor of the text decoration line.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
double Scale factor.

OH_Drawing_SetTextStyleEllipsis()

void OH_Drawing_SetTextStyleEllipsis (OH_Drawing_TextStyle * , const char *  )

Description

Sets the ellipsis content for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
char* Pointer to the ellipsis content. The data type is a pointer pointing to char.

OH_Drawing_SetTextStyleEllipsisModal()

void OH_Drawing_SetTextStyleEllipsisModal (OH_Drawing_TextStyle * , int  )

Description

Sets the ellipsis style for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Ellipsis style. For details about the available options, see OH_Drawing_EllipsisModal.

OH_Drawing_SetTextStyleFontFamilies()

void OH_Drawing_SetTextStyleFontFamilies (OH_Drawing_TextStyle * , int , const char * fontFamilies[] )

Description

Sets the font families.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Number of font families.
char Pointer to the font families.

OH_Drawing_SetTextStyleFontHeight()

void OH_Drawing_SetTextStyleFontHeight (OH_Drawing_TextStyle * , double  )

Description

Sets the font height.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
double Font height.

OH_Drawing_SetTextStyleFontSize()

void OH_Drawing_SetTextStyleFontSize (OH_Drawing_TextStyle * , double  )

Description

Sets the font size.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
double Font size.

OH_Drawing_SetTextStyleFontStyle()

void OH_Drawing_SetTextStyleFontStyle (OH_Drawing_TextStyle * , int  )

Description

Sets the font style.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Font style. For details about the available options, see OH_Drawing_FontStyle.

OH_Drawing_SetTextStyleFontWeight()

void OH_Drawing_SetTextStyleFontWeight (OH_Drawing_TextStyle * , int  )

Description

Sets the font weight.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
int Font weight. For details about the available options, see OH_Drawing_FontWeight.

OH_Drawing_SetTextStyleHalfLeading()

void OH_Drawing_SetTextStyleHalfLeading (OH_Drawing_TextStyle * , bool  )

Description

Sets half leading for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
bool Whether to enable half leading. The value true means to enable half lading, and false means the opposite.

OH_Drawing_SetTextStyleLetterSpacing()

void OH_Drawing_SetTextStyleLetterSpacing (OH_Drawing_TextStyle * , double  )

Description

Sets the letter spacing for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
double Letter spacing.

OH_Drawing_SetTextStyleLocale()

void OH_Drawing_SetTextStyleLocale (OH_Drawing_TextStyle * , const char *  )

Description

Sets the locale.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
char Pointer to the locale.

OH_Drawing_SetTextStyleWordSpacing()

void OH_Drawing_SetTextStyleWordSpacing (OH_Drawing_TextStyle * , double  )

Description

Sets the word spacing for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.
double Word spacing.

OH_Drawing_SetTypographyTextAlign()

void OH_Drawing_SetTypographyTextAlign (OH_Drawing_TypographyStyle * , int  )

Description

Sets the text alignment mode.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Text alignment mode. For details about the available options, see OH_Drawing_TextAlign.

OH_Drawing_SetTypographyTextBreakStrategy()

void OH_Drawing_SetTypographyTextBreakStrategy (OH_Drawing_TypographyStyle * , int  )

Description

Sets the text break strategy.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Text break strategy. For details about the available options, see OH_Drawing_BreakStrategy.

OH_Drawing_SetTypographyTextDirection()

void OH_Drawing_SetTypographyTextDirection (OH_Drawing_TypographyStyle * , int  )

Description

Sets the text direction.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Text direction. For details about the available options, see OH_Drawing_TextDirection.

OH_Drawing_SetTypographyTextEllipsisModal()

void OH_Drawing_SetTypographyTextEllipsisModal (OH_Drawing_TypographyStyle * , int  )

Description

Sets the ellipsis style for text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Ellipsis style. For details about the available options, see OH_Drawing_EllipsisModal.

OH_Drawing_SetTypographyTextMaxLines()

void OH_Drawing_SetTypographyTextMaxLines (OH_Drawing_TypographyStyle * , int  )

Description

Sets the maximum number of lines in the text.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Maximum number of lines.

OH_Drawing_SetTypographyTextWordBreakType()

void OH_Drawing_SetTypographyTextWordBreakType (OH_Drawing_TypographyStyle * , int  )

Description

Sets the word break type.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TypographyStyle Pointer to an OH_Drawing_TypographyStyle object, which is obtained by OH_Drawing_CreateTypographyStyle.
int Word break type. For details about the available options, see OH_Drawing_WordBreakType.

OH_Drawing_ShaderEffectCreateLinearGradient()

OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradient (const OH_Drawing_Point * startPt, const OH_Drawing_Point * endPt, const uint32_t * colors, const float * pos, uint32_t size, OH_Drawing_TileMode  )

Description

Creates an OH_Drawing_ShaderEffect object that generates a linear gradient between two points.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
startPt Start point.
endPt End point.
colors Colors to distribute.
pos Relative position of each color in the color array.
size Number of colors and positions.
OH_Drawing_TileMode Tile mode of the shader effect. For details about the available options, see OH_Drawing_TileMode.

Returns

Returns the pointer to the OH_Drawing_ShaderEffect object created.

OH_Drawing_ShaderEffectCreateRadialGradient()

OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient (const OH_Drawing_Point * centerPt, float radius, const uint32_t * colors, const float * pos, uint32_t size, OH_Drawing_TileMode  )

Description

Creates an OH_Drawing_ShaderEffect object that generates a radial gradient based on the center and radius of a circle. The radial gradient transitions colors from the center to the ending shape in a radial manner.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
centerPt Center of the circle.
radius Radius of the circle.
colors Colors to distribute.
pos Relative position of each color in the color array.
size Number of colors and positions.
OH_Drawing_TileMode Tile mode of the shader effect. For details about the available options, see OH_Drawing_TileMode.

Returns

Returns the pointer to the OH_Drawing_ShaderEffect object created.

OH_Drawing_ShaderEffectCreateSweepGradient()

OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient (const OH_Drawing_Point * centerPt, const uint32_t * colors, const float * pos, uint32_t size, OH_Drawing_TileMode  )

Description

Creates an OH_Drawing_ShaderEffect object that generates a sweep gradient based on the center.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
centerPt Center of the circle.
colors Colors to distribute.
pos Relative position of each color in the color array.
size Number of colors and positions.
OH_Drawing_TileMode Tile mode of the shader effect. For details about the available options, see OH_Drawing_TileMode.

Returns

Returns the pointer to the OH_Drawing_ShaderEffect object created.

OH_Drawing_ShaderEffectDestroy()

void OH_Drawing_ShaderEffectDestroy (OH_Drawing_ShaderEffect * )

Description

Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_ShaderEffect Pointer to an OH_Drawing_ShaderEffect object.

OH_Drawing_TextBlobBuilderAllocRunPos()

const OH_Drawing_RunBuffer* OH_Drawing_TextBlobBuilderAllocRunPos (OH_Drawing_TextBlobBuilder * , const OH_Drawing_Font * , int32_t count, const OH_Drawing_Rect *  )

Description

Allocates a run to store glyphs and positions. The pointer returned does not need to be managed by the caller. It can no longer be used after OH_Drawing_TextBlobBuilderMake is called.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBlobBuilder Pointer to an OH_Drawing_TextBlobBuilder object.
OH_Drawing_Font Pointer to an OH_Drawing_Font object.
count Number of text blobs.
OH_Drawing_Rect Rectangle of the text blob.

OH_Drawing_TextBlobBuilderCreate()

OH_Drawing_TextBlobBuilder* OH_Drawing_TextBlobBuilderCreate (void )

Description

Creates an OH_Drawing_TextBlobBuilder object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_TextBlobBuilder object created.

OH_Drawing_TextBlobBuilderDestroy()

void OH_Drawing_TextBlobBuilderDestroy (OH_Drawing_TextBlobBuilder * )

Description

Destroys an OH_Drawing_TextBlobBuilder object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBlobBuilder Pointer to an OH_Drawing_TextBlobBuilder object.

OH_Drawing_TextBlobBuilderMake()

OH_Drawing_TextBlob* OH_Drawing_TextBlobBuilderMake (OH_Drawing_TextBlobBuilder * )

Description

Makes an OH_Drawing_TextBlob object from an OH_Drawing_TextBlobBuilder.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBlobBuilder Pointer to an OH_Drawing_TextBlobBuilder object.

Returns

Returns the pointer to the OH_Drawing_TextBlob object created.

OH_Drawing_TextBlobDestroy()

void OH_Drawing_TextBlobDestroy (OH_Drawing_TextBlob * )

Description

Destroys an OH_Drawing_TextBlob object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TextBlob Pointer to an OH_Drawing_TextBlob object.

OH_Drawing_TypefaceCreateDefault()

OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault (void )

Description

Creates an OH_Drawing_Typeface object, which defines the default font.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Returns

Returns the pointer to the OH_Drawing_Typeface object created.

OH_Drawing_TypefaceDestroy()

void OH_Drawing_TypefaceDestroy (OH_Drawing_Typeface * )

Description

Destroys an OH_Drawing_Typeface object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typeface Pointer to an OH_Drawing_Typeface object.

OH_Drawing_TypographyDidExceedMaxLines()

bool OH_Drawing_TypographyDidExceedMaxLines (OH_Drawing_Typography * )

Description

Checks whether the maximum number of lines is exceeded.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns true if the maximum number of lines is exceeded; returns false otherwise.

OH_Drawing_TypographyGetAlphabeticBaseline()

double OH_Drawing_TypographyGetAlphabeticBaseline (OH_Drawing_Typography * )

Description

Obtains the alphabetic baseline.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the alphabetic baseline.

OH_Drawing_TypographyGetGlyphPositionAtCoordinate()

OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinate (OH_Drawing_Typography * , double , double  )

Description

Obtains the position and affinity of the glyph at the given coordinates.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
double X coordinate.
double Y coordinate.

Returns

Returns the OH_Drawing_PositionAndAffinity struct that holds the position and affinity of the glyph.

OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster()

OH_Drawing_PositionAndAffinity* OH_Drawing_TypographyGetGlyphPositionAtCoordinateWithCluster (OH_Drawing_Typography * , double , double  )

Description

Obtains the position and affinity of the glyph cluster to which the glyph at the given coordinates belongs. The glyph cluster is a container that holds one or more glyphs.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
double X coordinate.
double Y coordinate.

Returns

Returns the OH_Drawing_PositionAndAffinity struct that holds the position and affinity of the glyph cluster.

OH_Drawing_TypographyGetHeight()

double OH_Drawing_TypographyGetHeight (OH_Drawing_Typography * )

Description

Obtains the height.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the height.

OH_Drawing_TypographyGetIdeographicBaseline()

double OH_Drawing_TypographyGetIdeographicBaseline (OH_Drawing_Typography * )

Description

Obtains the ideographic baseline.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the ideographic baseline.

OH_Drawing_TypographyGetLineCount()

size_t OH_Drawing_TypographyGetLineCount (OH_Drawing_Typography * )

Description

Obtains the number of lines.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the number of lines.

OH_Drawing_TypographyGetLineHeight()

double OH_Drawing_TypographyGetLineHeight (OH_Drawing_Typography * , int  )

Description

Obtains the height of a given line.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
int Target line.

Returns

Returns the height.

OH_Drawing_TypographyGetLineWidth()

double OH_Drawing_TypographyGetLineWidth (OH_Drawing_Typography * , int  )

Description

Obtains the width of a given line.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
int Target line.

Returns

Returns the width.

OH_Drawing_TypographyGetLongestLine()

double OH_Drawing_TypographyGetLongestLine (OH_Drawing_Typography * )

Description

Obtains the longest line.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the longest line.

OH_Drawing_TypographyGetMaxIntrinsicWidth()

double OH_Drawing_TypographyGetMaxIntrinsicWidth (OH_Drawing_Typography * )

Description

Obtains the maximum intrinsic width.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the maximum intrinsic width.

OH_Drawing_TypographyGetMaxWidth()

double OH_Drawing_TypographyGetMaxWidth (OH_Drawing_Typography * )

Description

Obtains the maximum width.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the maximum width.

OH_Drawing_TypographyGetMinIntrinsicWidth()

double OH_Drawing_TypographyGetMinIntrinsicWidth (OH_Drawing_Typography * )

Description

Obtains the minimum intrinsic width.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 9

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the minimum intrinsic width.

OH_Drawing_TypographyGetRectsForPlaceholders()

OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForPlaceholders (OH_Drawing_Typography * )

Description

Obtains text boxes for placeholders.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.

Returns

Returns the OH_Drawing_TextBox struct that holds the text boxes.

OH_Drawing_TypographyGetRectsForRange()

OH_Drawing_TextBox* OH_Drawing_TypographyGetRectsForRange (OH_Drawing_Typography * , size_t , size_t , OH_Drawing_RectHeightStyle , OH_Drawing_RectWidthStyle  )

Description

Obtains text boxes in a given range.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
size_t Start position.
size_t End position.
OH_Drawing_RectHeightStyle Height style. For details about the available options, see OH_Drawing_RectHeightStyle.
OH_Drawing_RectWidthStyle Width style. For details about the available options, see OH_Drawing_RectWidthStyle.

Returns

Returns the OH_Drawing_TextBox struct that holds the text boxes.

OH_Drawing_TypographyGetWordBoundary()

OH_Drawing_Range* OH_Drawing_TypographyGetWordBoundary (OH_Drawing_Typography * , size_t  )

Description

Obtains the word boundary.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
size_t Index of the word.

Returns

Returns the OH_Drawing_Range struct that holds the word boundary.

OH_Drawing_TypographyHandlerAddPlaceholder()

void OH_Drawing_TypographyHandlerAddPlaceholder (OH_Drawing_TypographyCreate * , OH_Drawing_PlaceholderSpan *  )

Description

Adds a placeholder.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.
OH_Drawing_PlaceholderSpan Pointer to an OH_Drawing_PlaceholderSpan object.

OH_Drawing_TypographyHandlerAddText()

void OH_Drawing_TypographyHandlerAddText (OH_Drawing_TypographyCreate * , const char *  )

Description

Sets the text content.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.
char Pointer to the text content.

OH_Drawing_TypographyHandlerPopTextStyle()

void OH_Drawing_TypographyHandlerPopTextStyle (OH_Drawing_TypographyCreate * )

Description

Removes the topmost style in the stack, leaving the remaining styles in effect.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.

OH_Drawing_TypographyHandlerPushTextStyle()

void OH_Drawing_TypographyHandlerPushTextStyle (OH_Drawing_TypographyCreate * , OH_Drawing_TextStyle *  )

Description

Sets the text style.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_TypographyCreate Pointer to an OH_Drawing_TypographyCreate object. The pointer is obtained by OH_Drawing_CreateTypographyHandler.
OH_Drawing_TextStyle Pointer to an OH_Drawing_TextStyle object, which is obtained by OH_Drawing_CreateTextStyle.

OH_Drawing_TypographyLayout()

void OH_Drawing_TypographyLayout (OH_Drawing_Typography * , double  )

Description

Lays out the typography.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
double Maximum text width.

OH_Drawing_TypographyPaint()

void OH_Drawing_TypographyPaint (OH_Drawing_Typography * , OH_Drawing_Canvas * , double , double  )

Description

Paints text on the canvas.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

Name Description
OH_Drawing_Typography Pointer to an OH_Drawing_Typography object, which is obtained by OH_Drawing_CreateTypography.
OH_Drawing_Canvas Pointer to an OH_Drawing_Canvas object, which is obtained by OH_Drawing_CanvasCreate.
double X coordinate.
double Y coordinate.