microvg  5.0.0
microvg
microvg_gradient.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2022-2023 MicroEJ Corp. All rights reserved.
5  * Use of this source code is governed by a BSD-style license that can be found with this software.
6  */
7 
15 #if !defined MICROVG_GRADIENT_H
16 #define MICROVG_GRADIENT_H
17 
18 #if defined __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "microvg_configuration.h"
23 
24 #if defined (VG_FEATURE_GRADIENT) && defined (VG_FEATURE_GRADIENT_FULL) && defined (VG_FEATURE_GRADIENT_FIRST_COLOR)
25 
26 #if ((VG_FEATURE_GRADIENT != VG_FEATURE_GRADIENT_FULL) && (VG_FEATURE_GRADIENT != VG_FEATURE_GRADIENT_FIRST_COLOR))
27 #error "Specify a value for VG_FEATURE_GRADIENT"
28 #endif
29 
30 // -----------------------------------------------------------------------------
31 // Includes
32 // -----------------------------------------------------------------------------
33 
34 #include <sni.h>
35 
36 // -----------------------------------------------------------------------------
37 // Structs
38 // -----------------------------------------------------------------------------
39 
40 #if (VG_FEATURE_GRADIENT == VG_FEATURE_GRADIENT_FULL)
41 
42 /*
43  * @brief Map a jint array that represents a linear gradient
44  */
45 typedef struct {
46  jint count; // number of colors and positions
47  jfloat x;
48  jfloat y;
49  jfloat angle;
50  jfloat length;
51  jint colors_offset;
52  jint positions_offset;
54 
55 // -----------------------------------------------------------------------------
56 // Specific gradient formatting functions [mandatory]
57 // -----------------------------------------------------------------------------
58 
59 /*
60  * @brief Gets the size of the gradient color scale where the gradient colors
61  * positions are stored.
62  *
63  * @return the gradient scale size
64  */
65 float MICROVG_GRADIENT_get_gradient_scale_size(void);
66 
67 // -----------------------------------------------------------------------------
68 // Specific gradient formatting functions [optional]
69 // -----------------------------------------------------------------------------
70 
71 /*
72  * @brief Gets the gradient's array header size.
73  *
74  * The default implementation returns sizeof(MICROVG_GRADIENT_HEADER_t) / sizeof(uint32_t).
75  *
76  * @return the size in 32-bit format ("1" means 4 bytes)
77  */
78 uint32_t MICROVG_GRADIENT_get_gradient_header_size(void);
79 
80 #endif // #if (VG_FEATURE_GRADIENT == VG_FEATURE_GRADIENT_FULL)
81 
82 // -----------------------------------------------------------------------------
83 // EOF
84 // -----------------------------------------------------------------------------
85 
86 #endif // VG_FEATURE_GRADIENT
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif // !defined MICROVG_GRADIENT_H
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities...