From 519862e6f108e929d03912c8450310e41eff7df7 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Wed, 16 Mar 2022 10:57:07 +0800 Subject: [PATCH] Added English docs Signed-off-by: wusongqing --- .../graphic/native_drawing/drawing_bitmap.h | 130 ++++++++++ .../graphic/native_drawing/drawing_brush.h | 114 +++++++++ .../graphic/native_drawing/drawing_canvas.h | 179 ++++++++++++++ .../graphic/native_drawing/drawing_color.h | 64 +++++ .../graphic/native_drawing/drawing_path.h | 160 ++++++++++++ .../graphic/native_drawing/drawing_pen.h | 232 ++++++++++++++++++ .../graphic/native_drawing/drawing_types.h | 128 ++++++++++ 7 files changed, 1007 insertions(+) create mode 100644 en/native_sdk/graphic/native_drawing/drawing_bitmap.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_brush.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_canvas.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_color.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_path.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_pen.h create mode 100644 en/native_sdk/graphic/native_drawing/drawing_types.h diff --git a/en/native_sdk/graphic/native_drawing/drawing_bitmap.h b/en/native_sdk/graphic/native_drawing/drawing_bitmap.h new file mode 100644 index 00000000..3e7fecfc --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_bitmap.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_BITMAP_H +#define C_INCLUDE_DRAWING_BITMAP_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_bitmap.h + * + * @brief Declares functions related to the bitmap object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the pixel format of a bitmap, including the color type and alpha type. + * + * @since 8 + * @version 1.0 + */ +typedef struct { + /** Storage format of bitmap pixels */ + OH_Drawing_ColorFormat colorFormat; + /** Alpha format of bitmap pixels */ + OH_Drawing_AlphaFormat alphaFormat; +} OH_Drawing_BitmapFormat; + +/** + * @brief Creates an OH_Drawing_Bitmap object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Bitmap object created. + * @since 8 + * @version 1.0 + */ +OH_Drawing_Bitmap* OH_Drawing_BitmapCreate(void); + +/** + * @brief Destroys an OH_Drawing_Bitmap object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_BitmapDestroy(OH_Drawing_Bitmap*); + +/** + * @brief Initializes the width and height of an OH_Drawing_Bitmap object and sets the pixel format for the bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param width Indicates the width of the bitmap to be initialized. + * @param height Indicates the height of the bitmap to be initialized. + * @param OH_Drawing_BitmapFormat Indicates the pixel format of the bitmap to be initialized, including the pixel color type and alpha type. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_BitmapBuild( + OH_Drawing_Bitmap*, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat*); + +/** + * @brief Obtains the width of a bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns the width. + * @since 8 + * @version 1.0 + */ +uint32_t OH_Drawing_BitmapGetWidth(OH_Drawing_Bitmap*); + +/** + * @brief Obtains the height of a bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns the height. + * @since 8 + * @version 1.0 + */ +uint32_t OH_Drawing_BitmapGetHeight(OH_Drawing_Bitmap*); + +/** + * @brief Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns the pixel address. + * @since 8 + * @version 1.0 + */ +void* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_brush.h b/en/native_sdk/graphic/native_drawing/drawing_brush.h new file mode 100644 index 00000000..e81d367e --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_brush.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_BRUSH_H +#define C_INCLUDE_DRAWING_BRUSH_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_brush.h + * + * @brief Declares functions related to the brush object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_Brush object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Brush object created. + * @since 8 + * @version 1.0 + */ +OH_Drawing_Brush* OH_Drawing_BrushCreate(void); + +/** + * @brief Destroys an OH_Drawing_Brush object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_BrushDestroy(OH_Drawing_Brush*); + +/** + * @brief Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @return Returns true if anti-aliasing is enabled; returns false otherwise. + * @since 8 + * @version 1.0 + */ +bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush*); + +/** + * @brief Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @param bool Specifies whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush*, bool); + +/** + * @brief Obtains the color of a brush. The color is used by the brush to fill in a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @return Returns a 32-bit (ARGB) variable that describes the color. + * @since 8 + * @version 1.0 + */ +uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush*); + +/** + * @brief Sets the color for a brush. The color will be used by the brush to fill in a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @param color Indicates the color to set, which is a 32-bit (ARGB) variable. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_BrushSetColor(OH_Drawing_Brush*, uint32_t color); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_canvas.h b/en/native_sdk/graphic/native_drawing/drawing_canvas.h new file mode 100644 index 00000000..490caa8d --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_canvas.h @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_H +#define C_INCLUDE_DRAWING_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_canvas.h + * + * @brief Declares functions related to the canvas object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_Canvas object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Canvas object created. + * @since 8 + * @version 1.0 + */ +OH_Drawing_Canvas* OH_Drawing_CanvasCreate(void); + +/** + * @brief Destroys an OH_Drawing_Canvas object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasDestroy(OH_Drawing_Canvas*); + +/** + * @brief 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). + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasBind(OH_Drawing_Canvas*, OH_Drawing_Bitmap*); + +/** + * @brief Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasAttachPen(OH_Drawing_Canvas*, const OH_Drawing_Pen*); + +/** + * @brief Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasDetachPen(OH_Drawing_Canvas*); + +/** + * @brief Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasAttachBrush(OH_Drawing_Canvas*, const OH_Drawing_Brush*); + +/** + * @brief Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasDetachBrush(OH_Drawing_Canvas*); + +/** + * @brief Saves the current canvas status (canvas matrix) to the top of the stack. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasSave(OH_Drawing_Canvas*); + +/** + * @brief Restores the canvas status (canvas matrix) saved on the top of the stack. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasRestore(OH_Drawing_Canvas*); + +/** + * @brief Draws a line segment. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param x1 Indicates the x coordinate of the start point of the line segment. + * @param y1 Indicates the y coordinate of the start point of the line segment. + * @param x2 Indicates the x coordinate of the end point of the line segment. + * @param y2 Indicates the y coordinate of the end point of the line segment. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasDrawLine(OH_Drawing_Canvas*, float x1, float y1, float x2, float y2); + +/** + * @brief Draws a path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*); + +/** + * @brief Clears a canvas by using a specified color. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param color Indicates the color, which is a 32-bit (ARGB) variable. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_color.h b/en/native_sdk/graphic/native_drawing/drawing_color.h new file mode 100644 index 00000000..2aef9851 --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_color.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_COLOR_H +#define C_INCLUDE_DRAWING_COLOR_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_color.h + * + * @brief Declares functions related to the color object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param alpha Indicates a variable that describes alpha. The value ranges from 0x00 to 0xFF. + * @param red Indicates a variable that describes red. The value ranges from 0x00 to 0xFF. + * @param green Indicates a variable that describes green. The value ranges from 0x00 to 0xFF. + * @param blue Indicates a variable that describes blue. The value ranges from 0x00 to 0xFF. + * @return Returns a 32-bit (ARGB) variable that describes the color. + * @since 8 + * @version 1.0 + */ +uint32_t OH_Drawing_ColorSetArgb(uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_path.h b/en/native_sdk/graphic/native_drawing/drawing_path.h new file mode 100644 index 00000000..1740c932 --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_path.h @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_PATH_H +#define C_INCLUDE_DRAWING_PATH_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_path.h + * + * @brief Declares functions related to the path object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_Path object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Path object created. + * @since 8 + * @version 1.0 + */ +OH_Drawing_Path* OH_Drawing_PathCreate(void); + +/** + * @brief Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathDestroy(OH_Drawing_Path*); + +/** + * @brief Sets the start point of a path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param x Indicates the x coordinate of the start point. + * @param y Indicates the y coordinate of the start point. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathMoveTo(OH_Drawing_Path*, float x, float y); + +/** + * @brief Draws a line segment from the last point of a path to the target point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param x Indicates the x coordinate of the target point. + * @param y Indicates the y coordinate of the target point. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathLineTo(OH_Drawing_Path*, float x, float y); + +/** + * @brief 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. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param x1 Indicates the x coordinate of the upper left corner of the rectangle. + * @param y1 Indicates the y coordinate of the upper left corner of the rectangle. + * @param x2 Indicates the x coordinate of the lower right corner of the rectangle. + * @param y3 Indicates the y coordinate of the lower right corner of the rectangle. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathArcTo(OH_Drawing_Path*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); + +/** + * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param ctrlX Indicates the x coordinate of the control point. + * @param ctrlY Indicates the y coordinate of the control point. + * @param endX Indicates the x coordinate of the target point. + * @param endY Indicates the y coordinate of the target point. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY); + +/** + * @brief Draws a cubic Bezier curve from the last point of a path to the target point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param ctrlX1 Indicates the x coordinate of the first control point. + * @param ctrlY1 Indicates the y coordinate of the first control point. + * @param ctrlX2 Indicates the x coordinate of the second control point. + * @param ctrlY2 Indicates the y coordinate of the second control point. + * @param endX Indicates the x coordinate of the target point. + * @param endY Indicates the y coordinate of the target point. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathCubicTo( + OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); + +/** + * @brief Closes a path. A line segment from the start point to the last point of the path is added. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathClose(OH_Drawing_Path*); + +/** + * @brief Resets path data. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PathReset(OH_Drawing_Path*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_pen.h b/en/native_sdk/graphic/native_drawing/drawing_pen.h new file mode 100644 index 00000000..5d781bf6 --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_pen.h @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_PEN_H +#define C_INCLUDE_DRAWING_PEN_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_pen.h + * + * @brief Declares functions related to the pen object in the drawing module. + * + * @since 8 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_Pen object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Pen object created. + * @since 8 + * @version 1.0 + */ +OH_Drawing_Pen* OH_Drawing_PenCreate(void); + +/** + * @brief Destroys an OH_Drawing_Pen object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenDestroy(OH_Drawing_Pen*); + +/** + * @brief Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns true if anti-aliasing is enabled; returns false otherwise. + * @since 8 + * @version 1.0 + */ +bool OH_Drawing_PenIsAntiAlias(const OH_Drawing_Pen*); + +/** + * @brief Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param bool Specifies whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetAntiAlias(OH_Drawing_Pen*, bool); + +/** + * @brief Obtains the color of a pen. The color is used by the pen to outline a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns a 32-bit (ARGB) variable that describes the color. + * @since 8 + * @version 1.0 + */ +uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen*); + +/** + * @brief Sets the color for a pen. The color is used by the pen to outline a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param color Indicates the color to set, which is a 32-bit (ARGB) variable. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetColor(OH_Drawing_Pen*, uint32_t color); + +/** + * @brief Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns the thickness. + * @since 8 + * @version 1.0 + */ +float OH_Drawing_PenGetWidth(const OH_Drawing_Pen*); + +/** + * @brief Sets the thickness for a pen. This thickness determines the width of the outline of a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param width Indicates the thickness to set, which is a variable. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetWidth(OH_Drawing_Pen*, float width); + +/** + * @brief 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. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns the miter limit. + * @since 8 + * @version 1.0 + */ +float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen*); + +/** + * @brief 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. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param miter Indicates a variable that describes the miter limit. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen*, float miter); + +/** + * @brief Enumerates 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 + * @version 1.0 + */ +typedef enum { + /** There is no cap style. Both ends of the line segment are cut off square. */ + LINE_FLAT_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_SQUARE_CAP, + /** Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment. */ + LINE_ROUND_CAP +} OH_Drawing_PenLineCapStyle; + +/** + * @brief Obtains the line cap style of a pen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns the line cap style. + * @since 8 + * @version 1.0 + */ +OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen*); + +/** + * @brief Sets the line cap style for a pen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param OH_Drawing_PenLineCapStyle Indicates a variable that describes the line cap style. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetCap(OH_Drawing_Pen*, OH_Drawing_PenLineCapStyle); + +/** + * @brief Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. + * + * @since 8 + * @version 1.0 + */ +typedef enum { + /** 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_MITER_JOIN, + /** Round corner. */ + LINE_ROUND_JOIN, + /** Beveled corner. */ + LINE_BEVEL_JOIN +} OH_Drawing_PenLineJoinStyle; + +/** + * @brief Obtains the line join style of a pen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @return Returns the line join style. + * @since 8 + * @version 1.0 + */ +OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen*); + +/** + * @brief Sets the line join style for a pen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param OH_Drawing_PenLineJoinStyle Indicates a variable that describes the line join style. + * @since 8 + * @version 1.0 + */ +void OH_Drawing_PenSetJoin(OH_Drawing_Pen*, OH_Drawing_PenLineJoinStyle); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/en/native_sdk/graphic/native_drawing/drawing_types.h b/en/native_sdk/graphic/native_drawing/drawing_types.h new file mode 100644 index 00000000..24280237 --- /dev/null +++ b/en/native_sdk/graphic/native_drawing/drawing_types.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_DRAWING_TYPES_H +#define C_INCLUDE_DRAWING_TYPES_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_types.h + * + * @brief Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path. + * + * @since 8 + * @version 1.0 + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_Drawing_Canvas OH_Drawing_Canvas; + +/** + * @brief Defines a pen, which is used to describe the style and color to outline a shape. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_Drawing_Pen OH_Drawing_Pen; + +/** + * @brief Defines as a brush, which is used to describe the style and color to fill in a shape. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_Drawing_Brush OH_Drawing_Brush; + +/** + * @brief Defines a path, which is used to customize various shapes. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_Drawing_Path OH_Drawing_Path; + +/** + * @brief Defines a bitmap, which is a memory that contains the pixel data of a shape. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap; + +/** + * @brief Enumerates storage formats of bitmap pixels. + * + * @since 8 + * @version 1.0 + */ +typedef enum { + /** Unknown format. */ + COLOR_FORMAT_UNKNOWN, + /** Each pixel is represented by 8 bits, which together indicate alpha. */ + COLOR_FORMAT_ALPHA_8, + /** 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_RGB_565, + /** 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_ARGB_4444, + /** 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_RGBA_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. */ + COLOR_FORMAT_BGRA_8888 +} OH_Drawing_ColorFormat; + +/** + * @brief Enumerates alpha formats of bitmap pixels. + * + * @since 8 + * @version 1.0 + */ +typedef enum { + /** Unknown format. */ + ALPHA_FORMAT_UNKNOWN, + /** The bitmap does not have the alpha component. */ + ALPHA_FORMAT_OPAQUE, + /** The color component of each pixel is premultiplied by the alpha component. */ + ALPHA_FORMAT_PREMUL, + /** The color component of each pixel is not premultiplied by the alpha component. */ + ALPHA_FORMAT_UNPREMUL +} OH_Drawing_AlphaFormat; + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif -- Gitee