1 /* TSI 2023.xmo */ 2 /******************************************************************************* 3 * Copyright (c) 2023 Think Silicon Single Member PC 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this header file and/or associated documentation files to use, copy, 7 * modify, merge, publish, distribute, sublicense, and/or sell copies of the 8 * Materials, and to permit persons to whom the Materials are furnished to do 9 * so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Materials. 13 * 14 * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS 15 * NEMAGFX API. THE UNMODIFIED, NORMATIVE VERSIONS OF THINK-SILICON NEMAGFX 16 * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT: 17 * https://think-silicon.com/products/software/nemagfx-api 18 * 19 * The software is provided 'as is', without warranty of any kind, express or 20 * implied, including but not limited to the warranties of merchantability, 21 * fitness for a particular purpose and noninfringement. In no event shall 22 * Think Silicon Single Member PC be liable for any claim, damages or other 23 * liability, whether in an action of contract, tort or otherwise, arising 24 * from, out of or in connection with the software or the use or other dealings 25 * in the software. 26 ******************************************************************************/ 27 28 /** 29 * @file 30 * @brief Paint operation related fuctions. Paint is an internal (opaque) struct of NemaVG. 31 * The functions defined here can be used access its parameters. 32 * 33 */ 34 35 #ifndef __NEMA_VG_PAINT_H__ 36 #define __NEMA_VG_PAINT_H__ 37 38 #include "nema_interpolators.h" 39 #include "nema_matrix3x3.h" 40 #include "nema_vg_context.h" 41 #include "nema_graphics.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 #define NEMA_VG_PAINT_COLOR (0x00U) /**< Fill with color */ 48 #define NEMA_VG_PAINT_FILL (0x00U) /**< Deprecated - Fill with color (same as NEMA_VG_PAINT_COLOR) */ 49 #define NEMA_VG_PAINT_GRAD_LINEAR (0x01U) /**< Fill with linear gradient */ 50 #define NEMA_VG_PAINT_TEXTURE (0x02U) /**< Fill with texture */ 51 #define NEMA_VG_PAINT_GRAD_RADIAL (0x03U) /**< Fill with radial gradient */ 52 #define NEMA_VG_PAINT_GRAD_CONICAL (0x04U) /**< Fill with conical gradient */ 53 54 #define NEMA_VG_PAINT_MAX_GRAD_STOPS (32) /**< Maximum gradient stops*/ 55 56 /** \brief Create a paint object. 57 * 58 * \return Handle to the created paint object 59 * 60 */ 61 NEMA_VG_PAINT_HANDLE nema_vg_paint_create(); 62 63 /** \brief Destroy a paint object. 64 * 65 * \param paint Handle to paint object that should be destroyed 66 * 67 */ 68 void nema_vg_paint_destroy(NEMA_VG_PAINT_HANDLE paint); 69 70 /** \brief Clear the parameters of a paint object. 71 * 72 * \param paint Pointer (handle) to paint object 73 * 74 */ 75 void nema_vg_paint_clear(NEMA_VG_PAINT_HANDLE paint); 76 77 /** \brief Set the paint type 78 * 79 * \param paint Pointer (handle) to paint 80 * \param type Paint type (NEMA_VG_PAINT_COLOR, NEMA_VG_PAINT_GRAD_LINEAR, NEMA_VG_PAINT_TEXTURE, NEMA_VG_PAINT_GRAD_RADIAL, NEMA_VG_PAINT_GRAD_CONICAL) 81 * 82 */ 83 void nema_vg_paint_set_type(NEMA_VG_PAINT_HANDLE paint, uint8_t type); 84 85 86 /** \brief Lock paint transformation to path. If locked, path and paint 87 * transformation will be in sync. 88 * 89 * \param paint Pointer to paint object 90 * \param locked 1 if locked (default), 0 if not locked 91 * 92 */ 93 void nema_vg_paint_lock_tran_to_path(NEMA_VG_PAINT_HANDLE paint, int locked); 94 95 /** \brief Set linear gradient to a paint object 96 * 97 * \param paint Pointer to paint object 98 * \param grad Pointer to gradient object 99 * \param x0 Linear gradient start point x coordinate 100 * \param y0 Linear gradient start point y coordinate 101 * \param x1 Linear gradient end point x coordinate 102 * \param y1 Linear gradient end point y coordinate 103 * \param sampling_mode Sampling mode. NEMA_TEX_BORDER defaults to NEMA_TEX_CLAMP 104 * 105 */ 106 void nema_vg_paint_set_grad_linear(NEMA_VG_PAINT_HANDLE paint, 107 NEMA_VG_GRAD_HANDLE grad, 108 float x0, float y0, 109 float x1, float y1, 110 nema_tex_mode_t sampling_mode); 111 112 /** \brief Set the paint color 113 * 114 * \param paint Pointer (handle) to paint object 115 * \param rgba Color to be set, in rgba (hex 0xAABBGGRR) format 116 * 117 */ 118 void nema_vg_paint_set_paint_color(NEMA_VG_PAINT_HANDLE paint, uint32_t rgba); 119 120 /** \brief Set the paint opacity 121 * 122 * \param paint Pointer (pointer) to paint object 123 * \param opacity Opacity to be set, 1 is fully opaque and 0 is fully transparent 124 * 125 */ 126 void nema_vg_paint_set_opacity(NEMA_VG_PAINT_HANDLE paint, float opacity); 127 128 /** \brief Set stroke width - DEPRECATED USE nema_vg_stroke_set_width 129 * 130 * \param paint Pointer (handle) to paint object 131 * \param stroke_width Stroke width to be set 132 * 133 */ 134 void nema_vg_paint_set_stroke_width(NEMA_VG_PAINT_HANDLE paint, float stroke_width); 135 136 /** \brief Set transformation matrix for texture 137 * 138 * \param paint Pointer (handle) to paint object 139 * \param m 3x3 transformation matrix 140 * 141 */ 142 void nema_vg_paint_set_tex_matrix(NEMA_VG_PAINT_HANDLE paint, nema_matrix3x3_t m); 143 144 /** \brief Set texture to paint object 145 * 146 * \param paint Pointer (handle) to paint 147 * \param text Pointer to texture image object 148 * 149 */ 150 void nema_vg_paint_set_tex(NEMA_VG_PAINT_HANDLE paint, nema_img_obj_t* tex); 151 152 /** \brief Set Lut-based (look-up-table) texture to paint object. See Nema Pixpresso User Manual regarding Lut formats 153 * 154 * \param paint Pointer (handle) to paint object 155 * \param lut_palette Pointer to the Palette of the Lut image object 156 * \param lut_indices Pointer to the indices of the Lut image object 157 * 158 */ 159 void nema_vg_paint_set_lut_tex(NEMA_VG_PAINT_HANDLE paint, nema_img_obj_t* lut_palette, nema_img_obj_t* lut_indices); 160 161 /** \brief Set Conical gradient to paint object 162 * 163 * \param paint Pointer (handle) to paint 164 * \param grad Pointer (handle) to gradient 165 * \param cx Conical gradient center point x coordinate 166 * \param cy Conical gradient center point y coordinate 167 * \param sampling_mode Sampling mode 168 * 169 */ 170 void nema_vg_paint_set_grad_conical(NEMA_VG_PAINT_HANDLE paint, 171 NEMA_VG_GRAD_HANDLE grad, 172 float cx, float cy, 173 nema_tex_mode_t sampling_mode); 174 175 /** \brief Set radial gradient to paint object 176 * 177 * \param paint Pointer (handle) to paint 178 * \param grad Pointer (handle) to gradient 179 * \param x0 Radial gradient center point x coordinate 180 * \param y0 Radial gradient center point y coordinate 181 * \param r Radial gradient radius 182 * \param sampling_mode Sampling mode 183 * 184 */ 185 void 186 nema_vg_paint_set_grad_radial(NEMA_VG_PAINT_HANDLE paint, 187 NEMA_VG_GRAD_HANDLE grad, 188 float x0, float y0, 189 float r, 190 nema_tex_mode_t sampling_mode); 191 192 193 /** \brief Set radial gradient to paint object, with different horizontal and vertical radius 194 * 195 * \param paint Pointer (handle) to paint 196 * \param grad Pointer (handle) to gradient 197 * \param x0 Radial gradient center point x coordinate 198 * \param y0 Radial gradient center point y coordinate 199 * \param rx Radial gradient radius on x axis 200 * \param ry Radial gradient radius on y axis 201 * \param sampling_mode Sampling mode 202 * 203 */ 204 void 205 nema_vg_paint_set_grad_radial2(NEMA_VG_PAINT_HANDLE paint, 206 NEMA_VG_GRAD_HANDLE grad, 207 float x0, float y0, 208 float rx, float ry, 209 nema_tex_mode_t sampling_mode); 210 211 /** \brief Create gradient object 212 * 213 * \return Handle (pointer) to the created gradient object 214 */ 215 NEMA_VG_GRAD_HANDLE 216 nema_vg_grad_create(void); 217 218 /** \brief Destroy gradient object 219 * 220 * \param grad Pointer to the gradient object 221 * 222 */ 223 void 224 nema_vg_grad_destroy(NEMA_VG_GRAD_HANDLE grad); 225 226 /** \brief Set gradient parameters to a gradient object 227 * 228 * \param grad Pointer (handle) to gradient object 229 * \param stops_count Number of stop colors 230 * \param stops Pointer to stop colors coordinates 231 * \param colors Pointer to stop color values 232 * 233 */ 234 void 235 nema_vg_grad_set(NEMA_VG_GRAD_HANDLE grad, int stops_count, float *stops, color_var_t* colors); 236 237 #ifdef __cplusplus 238 } 239 #endif 240 241 #endif //__NEMA_VG_PAINT_H__ 242