| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 |
| 19 | #ifndef _RLOTTIE_COMMON_H_ |
| 20 | #define _RLOTTIE_COMMON_H_ |
| 21 |
| 22 | #ifdef _WIN32 |
| 23 | #ifdef LOT_BUILD |
| 24 | #ifdef DLL_EXPORT |
| 25 | #define LOT_EXPORT __declspec(dllexport) |
| 26 | #else |
| 27 | #define LOT_EXPORT |
| 28 | #endif |
| 29 | #else |
| 30 | #define LOT_EXPORT __declspec(dllimport) |
| 31 | #endif |
| 32 | #else |
| 33 | #ifdef __GNUC__ |
| 34 | #if __GNUC__ >= 4 |
| 35 | #define LOT_EXPORT __attribute__((visibility("default"))) |
| 36 | #else |
| 37 | #define LOT_EXPORT |
| 38 | #endif |
| 39 | #else |
| 40 | #define LOT_EXPORT |
| 41 | #endif |
| 42 | #endif |
| 43 |
| 44 |
| 45 | /** |
| 46 | * @defgroup Lottie_Animation Lottie_Animation |
| 47 | * |
| 48 | * Lottie Animation is a modern style vector based animation design. Its animation |
| 49 | * resource(within json format) could be generated by Adobe After Effect using |
| 50 | * bodymovin plugin. You can find a good examples in Lottie Community which |
| 51 | * shares many free resources(see: www.lottiefiles.com). |
| 52 | * |
| 53 | * This Lottie_Animation is a common engine to manipulate, control Lottie |
| 54 | * Animation from the Lottie resource - json file. It provides a scene-graph |
| 55 | * node tree per frames by user demand as well as rasterized frame images. |
| 56 | * |
| 57 | */ |
| 58 |
| 59 | /** |
| 60 | * @ingroup Lottie_Animation |
| 61 | */ |
| 62 |
| 63 |
| 64 | /** |
| 65 | * @brief Enumeration for Lottie Player error code. |
| 66 | */ |
| 67 | typedef enum |
| 68 | { |
| 69 | //TODO: Coding convention?? |
| 70 | LOT_ANIMATION_ERROR_NONE = 0, |
| 71 | LOT_ANIMATION_ERROR_NOT_PERMITTED, |
| 72 | LOT_ANIMATION_ERROR_OUT_OF_MEMORY, |
| 73 | LOT_ANIMATION_ERROR_INVALID_PARAMETER, |
| 74 | LOT_ANIMATION_ERROR_RESULT_OUT_OF_RANGE, |
| 75 | LOT_ANIMATION_ERROR_ALREADY_IN_PROGRESS, |
| 76 | LOT_ANIMATION_ERROR_UNKNOWN |
| 77 | } LOTErrorType; |
| 78 |
| 79 | typedef enum |
| 80 | { |
| 81 | BrushSolid = 0, |
| 82 | BrushGradient |
| 83 | } LOTBrushType; |
| 84 |
| 85 | typedef enum |
| 86 | { |
| 87 | FillEvenOdd = 0, |
| 88 | FillWinding |
| 89 | } LOTFillRule; |
| 90 |
| 91 | typedef enum |
| 92 | { |
| 93 | JoinMiter = 0, |
| 94 | JoinBevel, |
| 95 | JoinRound |
| 96 | } LOTJoinStyle; |
| 97 |
| 98 | typedef enum |
| 99 | { |
| 100 | CapFlat = 0, |
| 101 | CapSquare, |
| 102 | CapRound |
| 103 | } LOTCapStyle; |
| 104 |
| 105 | typedef enum |
| 106 | { |
| 107 | GradientLinear = 0, |
| 108 | GradientRadial |
| 109 | } LOTGradientType; |
| 110 |
| 111 | typedef struct LOTGradientStop |
| 112 | { |
| 113 | float pos; |
| 114 | unsigned char r, g, b, a; |
| 115 | } LOTGradientStop; |
| 116 |
| 117 | typedef enum |
| 118 | { |
| 119 | MaskAdd = 0, |
| 120 | MaskSubstract, |
| 121 | MaskIntersect, |
| 122 | MaskDifference |
| 123 | } LOTMaskType; |
| 124 |
| 125 | typedef struct LOTMask { |
| 126 | struct { |
| 127 | const float *ptPtr; |
| 128 | int ptCount; |
| 129 | const char* elmPtr; |
| 130 | int elmCount; |
| 131 | } mPath; |
| 132 | LOTMaskType mMode; |
| 133 | int mAlpha; |
| 134 | }LOTMask; |
| 135 |
| 136 | typedef enum |
| 137 | { |
| 138 | MatteNone = 0, |
| 139 | MatteAlpha, |
| 140 | MatteAlphaInv, |
| 141 | MatteLuma, |
| 142 | MatteLumaInv |
| 143 | } LOTMatteType; |
| 144 |
| 145 | typedef struct LOTNode { |
| 146 |
| 147 | #define ChangeFlagNone 0x0000 |
| 148 | #define ChangeFlagPath 0x0001 |
| 149 | #define ChangeFlagPaint 0x0010 |
| 150 | #define ChangeFlagAll (ChangeFlagPath & ChangeFlagPaint) |
| 151 |
| 152 | struct { |
| 153 | const float *ptPtr; |
| 154 | int ptCount; |
| 155 | const char* elmPtr; |
| 156 | int elmCount; |
| 157 | } mPath; |
| 158 |
| 159 | struct { |
| 160 | unsigned char r, g, b, a; |
| 161 | } mColor; |
| 162 |
| 163 | struct { |
| 164 | unsigned char enable; |
| 165 | int width; |
| 166 | LOTCapStyle cap; |
| 167 | LOTJoinStyle join; |
| 168 | int meterLimit; |
| 169 | float* dashArray; |
| 170 | int dashArraySize; |
| 171 | } mStroke; |
| 172 |
| 173 | struct { |
| 174 | LOTGradientType type; |
| 175 | LOTGradientStop *stopPtr; |
| 176 | unsigned int stopCount; |
| 177 | struct { |
| 178 | float x, y; |
| 179 | } start, end, center, focal; |
| 180 | float cradius; |
| 181 | float fradius; |
| 182 | } mGradient; |
| 183 |
| 184 | struct { |
| 185 | unsigned char* data; |
| 186 | int width; |
| 187 | int height; |
| 188 | struct { |
| 189 | float m11; float m12; float m13; |
| 190 | float m21; float m22; float m23; |
| 191 | float m31; float m32; float m33; |
| 192 | } mMatrix; |
| 193 | } mImageInfo; |
| 194 |
| 195 | int mFlag; |
| 196 | LOTBrushType mBrushType; |
| 197 | LOTFillRule mFillRule; |
| 198 | } LOTNode; |
| 199 |
| 200 |
| 201 |
| 202 | typedef struct LOTLayerNode { |
| 203 |
| 204 | struct { |
| 205 | LOTMask *ptr; |
| 206 | unsigned int size; |
| 207 | } mMaskList; |
| 208 |
| 209 | struct { |
| 210 | const float *ptPtr; |
| 211 | int ptCount; |
| 212 | const char* elmPtr; |
| 213 | int elmCount; |
| 214 | } mClipPath; |
| 215 |
| 216 | struct { |
| 217 | struct LOTLayerNode **ptr; |
| 218 | unsigned int size; |
| 219 | } mLayerList; |
| 220 |
| 221 | struct { |
| 222 | LOTNode **ptr; |
| 223 | unsigned int size; |
| 224 | } mNodeList; |
| 225 |
| 226 | LOTMatteType mMatte; |
| 227 | int mVisible; |
| 228 | int mAlpha; |
| 229 | const char *name; |
| 230 |
| 231 | } LOTLayerNode; |
| 232 |
| 233 | /** |
| 234 | * @} |
| 235 | */ |
| 236 |
| 237 | #endif // _RLOTTIE_COMMON_H_ |
| 238 |