• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef C_INCLUDE_DRAWING_SHADER_EFFECT_H
17 #define C_INCLUDE_DRAWING_SHADER_EFFECT_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 11
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_shader_effect.h
33  *
34  * @brief Declares functions related to the <b>shaderEffect</b> object in the drawing module.
35  *
36  * @since 11
37  * @version 1.0
38  */
39 
40 #include "drawing_types.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Enumerates tile mode.
48  *
49  * @since 11
50  * @version 1.0
51  */
52 typedef enum {
53     /**
54      * Replicate the edge color if the shader effect draws outside of its original bounds.
55      */
56     CLAMP,
57     /**
58      * Repeat the shader effect image horizontally and vertically.
59      */
60     REPEAT,
61     /**
62      * Repeat the shader effect image horizontally and vertically, alternating mirror images
63      * so that adjacent images always seam.
64      */
65     MIRROR,
66     /**
67      * Only draw within the original domain, return transparent-black everywhere else.
68      */
69     DECAL,
70 } OH_Drawing_TileMode;
71 
72 /**
73  * @brief Creates an <b>OH_Drawing_ShaderEffect</b> that generates a linear gradient between the two specified points.
74  *
75  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
76  * @param startPt Indicates the start point for the gradient.
77  * @param endPt Indicates the end point for the gradient.
78  * @param colors Indicates the colors to be distributed between the two points.
79  * @param pos Indicates the relative position of each corresponding color in the colors array.
80  * @param size Indicates the number of colors and pos.
81  * @param OH_Drawing_TileMode Indicates the tile mode.
82  * @return Returns the pointer to the <b>OH_Drawing_ShaderEffect</b> object created.
83  * @since 11
84  * @version 1.0
85  */
86 OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateLinearGradient(const OH_Drawing_Point* startPt,
87     const OH_Drawing_Point* endPt, const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode);
88 
89 /**
90  * @brief Creates an <b>OH_Drawing_ShaderEffect</b> that generates a radial gradient given the center and radius.
91  *
92  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
93  * @param centerPt Indicates the center of the circle for the gradient.
94  * @param radius Indicates the radius of the circle for this gradient.
95  * @param colors Indicates the colors to be distributed between the two points.
96  * @param pos Indicates the relative position of each corresponding color in the colors array.
97  * @param size Indicates the number of colors and pos.
98  * @param OH_Drawing_TileMode Indicates the tile mode.
99  * @return Returns the pointer to the <b>OH_Drawing_ShaderEffect</b> object created.
100  * @since 11
101  * @version 1.0
102  */
103 OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient(const OH_Drawing_Point* centerPt, float radius,
104     const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode);
105 
106 /**
107  * @brief Creates an <b>OH_Drawing_ShaderEffect</b> that generates a sweep gradient given a center.
108  *
109  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
110  * @param centerPt Indicates the center of the circle for the gradient.
111  * @param colors Indicates the colors to be distributed between the two points.
112  * @param pos Indicates the relative position of each corresponding color in the colors array.
113  * @param size Indicates the number of colors and pos.
114  * @param OH_Drawing_TileMode Indicates the tile mode.
115  * @return Returns the pointer to the <b>OH_Drawing_ShaderEffect</b> object created.
116  * @since 11
117  * @version 1.0
118  */
119 OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Drawing_Point* centerPt,
120     const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode);
121 
122 /**
123  * @brief Destroys an <b>OH_Drawing_ShaderEffect</b> object and reclaims the memory occupied by the object.
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
126  * @param OH_Drawing_ShaderEffect Indicates the pointer to an <b>OH_Drawing_ShaderEffect</b> object.
127  * @since 11
128  * @version 1.0
129  */
130 void OH_Drawing_ShaderEffectDestroy(OH_Drawing_ShaderEffect*);
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 /** @} */
136 #endif
137