File indexing completed on 2025-01-19 03:59:59
0001 import { value_to_lottie, value_from_lottie, LottieObject } from '../base.js'; 0002 import { KeyframeBezierHandle } from './easing.js'; 0003 import { Bezier } from './bezier.js'; 0004 0005 /* 0006 */ 0007 export class Keyframe extends LottieObject 0008 { 0009 time; 0010 in_value; 0011 out_value; 0012 jump; 0013 0014 constructor() 0015 { 0016 super(); 0017 this.time = 0; 0018 this.in_value = null; 0019 this.out_value = null; 0020 this.jump = null; 0021 } 0022 0023 to_lottie() 0024 { 0025 var arr = {}; 0026 if ( this.time !== null ) 0027 arr["t"] = value_to_lottie(this.time); 0028 if ( this.in_value !== null ) 0029 arr["i"] = value_to_lottie(this.in_value); 0030 if ( this.out_value !== null ) 0031 arr["o"] = value_to_lottie(this.out_value); 0032 if ( this.jump !== null ) 0033 arr["h"] = value_to_lottie(Number(this.jump)); 0034 return arr; 0035 } 0036 0037 static from_lottie(arr) 0038 { 0039 var obj = new Keyframe(); 0040 if ( arr["t"] !== undefined ) 0041 obj.time = value_from_lottie(arr["t"]); 0042 if ( arr["i"] !== undefined ) 0043 obj.in_value = value_from_lottie(arr["i"]); 0044 if ( arr["o"] !== undefined ) 0045 obj.out_value = value_from_lottie(arr["o"]); 0046 if ( arr["h"] !== undefined ) 0047 obj.jump = value_from_lottie(Boolean(arr["h"])); 0048 return obj; 0049 } 0050 } 0051 0052 /*! 0053 Keyframe for MultiDimensional values 0054 0055 @par Bezier easing 0056 @parblock 0057 Imagine a quadratic bezier, with starting point at (0, 0) and end point at (1, 1). 0058 0059 \p out_value and \p in_value are the other two handles for a quadratic bezier, 0060 expressed as absoulte values in this 0-1 space. 0061 0062 See also https://cubic-bezier.com/ 0063 @endparblock 0064 */ 0065 export class OffsetKeyframe extends Keyframe 0066 { 0067 time; 0068 in_value; 0069 out_value; 0070 jump; 0071 start; 0072 end; 0073 in_tan; 0074 out_tan; 0075 0076 constructor() 0077 { 0078 super(); 0079 this.time = 0; 0080 this.in_value = null; 0081 this.out_value = null; 0082 this.jump = null; 0083 this.start = null; 0084 this.end = null; 0085 this.in_tan = null; 0086 this.out_tan = null; 0087 } 0088 0089 to_lottie() 0090 { 0091 var arr = {}; 0092 if ( this.time !== null ) 0093 arr["t"] = value_to_lottie(this.time); 0094 if ( this.in_value !== null ) 0095 arr["i"] = value_to_lottie(this.in_value); 0096 if ( this.out_value !== null ) 0097 arr["o"] = value_to_lottie(this.out_value); 0098 if ( this.jump !== null ) 0099 arr["h"] = value_to_lottie(Number(this.jump)); 0100 if ( this.start !== null ) 0101 arr["s"] = value_to_lottie(this.start); 0102 if ( this.end !== null ) 0103 arr["e"] = value_to_lottie(this.end); 0104 if ( this.in_tan !== null ) 0105 arr["ti"] = value_to_lottie(this.in_tan); 0106 if ( this.out_tan !== null ) 0107 arr["to"] = value_to_lottie(this.out_tan); 0108 return arr; 0109 } 0110 0111 static from_lottie(arr) 0112 { 0113 var obj = new OffsetKeyframe(); 0114 if ( arr["t"] !== undefined ) 0115 obj.time = value_from_lottie(arr["t"]); 0116 if ( arr["i"] !== undefined ) 0117 obj.in_value = value_from_lottie(arr["i"]); 0118 if ( arr["o"] !== undefined ) 0119 obj.out_value = value_from_lottie(arr["o"]); 0120 if ( arr["h"] !== undefined ) 0121 obj.jump = value_from_lottie(Boolean(arr["h"])); 0122 if ( arr["s"] !== undefined ) 0123 obj.start = value_from_lottie(arr["s"]); 0124 if ( arr["e"] !== undefined ) 0125 obj.end = value_from_lottie(arr["e"]); 0126 if ( arr["ti"] !== undefined ) 0127 obj.in_tan = value_from_lottie(arr["ti"]); 0128 if ( arr["to"] !== undefined ) 0129 obj.out_tan = value_from_lottie(arr["to"]); 0130 return obj; 0131 } 0132 } 0133 0134 /*! 0135 Keyframe holding Bezier objects 0136 */ 0137 export class ShapePropKeyframe extends Keyframe 0138 { 0139 time; 0140 in_value; 0141 out_value; 0142 jump; 0143 start; 0144 end; 0145 0146 constructor() 0147 { 0148 super(); 0149 this.time = 0; 0150 this.in_value = null; 0151 this.out_value = null; 0152 this.jump = null; 0153 this.start = null; 0154 this.end = null; 0155 } 0156 0157 to_lottie() 0158 { 0159 var arr = {}; 0160 if ( this.time !== null ) 0161 arr["t"] = value_to_lottie(this.time); 0162 if ( this.in_value !== null ) 0163 arr["i"] = value_to_lottie(this.in_value); 0164 if ( this.out_value !== null ) 0165 arr["o"] = value_to_lottie(this.out_value); 0166 if ( this.jump !== null ) 0167 arr["h"] = value_to_lottie(Number(this.jump)); 0168 if ( this.start !== null ) 0169 arr["s"] = value_to_lottie([this.start]); 0170 if ( this.end !== null ) 0171 arr["e"] = value_to_lottie([this.end]); 0172 return arr; 0173 } 0174 0175 static from_lottie(arr) 0176 { 0177 var obj = new ShapePropKeyframe(); 0178 if ( arr["t"] !== undefined ) 0179 obj.time = value_from_lottie(arr["t"]); 0180 if ( arr["i"] !== undefined ) 0181 obj.in_value = value_from_lottie(arr["i"]); 0182 if ( arr["o"] !== undefined ) 0183 obj.out_value = value_from_lottie(arr["o"]); 0184 if ( arr["h"] !== undefined ) 0185 obj.jump = value_from_lottie(Boolean(arr["h"])); 0186 if ( arr["s"] !== undefined ) 0187 obj.start = value_from_lottie(arr["s"][0]); 0188 if ( arr["e"] !== undefined ) 0189 obj.end = value_from_lottie(arr["e"][0]); 0190 return obj; 0191 } 0192 } 0193 0194 /*! 0195 An animatable property that holds a Bezier 0196 */ 0197 export class ShapeProperty extends LottieObject 0198 { 0199 value; 0200 property_index; 0201 animated; 0202 keyframes; 0203 0204 constructor() 0205 { 0206 super(); 0207 this.value = new Bezier(); 0208 this.property_index = null; 0209 this.animated = false; 0210 this.keyframes = null; 0211 } 0212 0213 to_lottie() 0214 { 0215 var arr = {}; 0216 if ( this.value !== null ) 0217 arr["k"] = value_to_lottie(this.value); 0218 if ( this.property_index !== null ) 0219 arr["ix"] = value_to_lottie(this.property_index); 0220 if ( this.animated !== null ) 0221 arr["a"] = value_to_lottie(Number(this.animated)); 0222 if ( this.keyframes !== null ) 0223 arr["k"] = value_to_lottie(this.keyframes); 0224 return arr; 0225 } 0226 0227 static from_lottie(arr) 0228 { 0229 var obj = new ShapeProperty(); 0230 if ( arr["k"] !== undefined ) 0231 obj.value = value_from_lottie(arr["k"]); 0232 if ( arr["ix"] !== undefined ) 0233 obj.property_index = value_from_lottie(arr["ix"]); 0234 if ( arr["a"] !== undefined ) 0235 obj.animated = value_from_lottie(Boolean(arr["a"])); 0236 if ( arr["k"] !== undefined ) 0237 obj.keyframes = value_from_lottie(arr["k"]); 0238 return obj; 0239 } 0240 } 0241 0242 /*! 0243 An animatable property that holds a float 0244 */ 0245 export class Value extends LottieObject 0246 { 0247 value; 0248 property_index; 0249 animated; 0250 keyframes; 0251 0252 constructor(value=null) 0253 { 0254 super(); 0255 this.property_index = null; 0256 this.animated = false; 0257 this.keyframes = null; 0258 this.value = value; 0259 } 0260 0261 to_lottie() 0262 { 0263 var arr = {}; 0264 if ( this.value !== null ) 0265 arr["k"] = value_to_lottie(this.value); 0266 if ( this.property_index !== null ) 0267 arr["ix"] = value_to_lottie(this.property_index); 0268 if ( this.animated !== null ) 0269 arr["a"] = value_to_lottie(Number(this.animated)); 0270 if ( this.keyframes !== null ) 0271 arr["k"] = value_to_lottie(this.keyframes); 0272 return arr; 0273 } 0274 0275 static from_lottie(arr) 0276 { 0277 var obj = new Value(); 0278 if ( arr["k"] !== undefined ) 0279 obj.value = value_from_lottie(arr["k"]); 0280 if ( arr["ix"] !== undefined ) 0281 obj.property_index = value_from_lottie(arr["ix"]); 0282 if ( arr["a"] !== undefined ) 0283 obj.animated = value_from_lottie(Boolean(arr["a"])); 0284 if ( arr["k"] !== undefined ) 0285 obj.keyframes = value_from_lottie(arr["k"]); 0286 return obj; 0287 } 0288 } 0289 0290 /*! 0291 An animatable property that holds a NVector 0292 */ 0293 export class MultiDimensional extends LottieObject 0294 { 0295 value; 0296 property_index; 0297 animated; 0298 keyframes; 0299 0300 constructor(value=null) 0301 { 0302 super(); 0303 this.property_index = null; 0304 this.animated = false; 0305 this.keyframes = null; 0306 this.value = value; 0307 } 0308 0309 to_lottie() 0310 { 0311 var arr = {}; 0312 if ( this.value !== null ) 0313 arr["k"] = value_to_lottie(this.value); 0314 if ( this.property_index !== null ) 0315 arr["ix"] = value_to_lottie(this.property_index); 0316 if ( this.animated !== null ) 0317 arr["a"] = value_to_lottie(Number(this.animated)); 0318 if ( this.keyframes !== null ) 0319 arr["k"] = value_to_lottie(this.keyframes); 0320 return arr; 0321 } 0322 0323 static from_lottie(arr) 0324 { 0325 var obj = new MultiDimensional(); 0326 if ( arr["k"] !== undefined ) 0327 obj.value = value_from_lottie(arr["k"]); 0328 if ( arr["ix"] !== undefined ) 0329 obj.property_index = value_from_lottie(arr["ix"]); 0330 if ( arr["a"] !== undefined ) 0331 obj.animated = value_from_lottie(Boolean(arr["a"])); 0332 if ( arr["k"] !== undefined ) 0333 obj.keyframes = value_from_lottie(arr["k"]); 0334 return obj; 0335 } 0336 } 0337 0338 /*! 0339 Represents colors and offsets in a gradient 0340 */ 0341 export class GradientColors extends LottieObject 0342 { 0343 colors; 0344 count; 0345 0346 constructor() 0347 { 0348 super(); 0349 this.colors = new MultiDimensional([]); 0350 this.count = 0; 0351 } 0352 0353 to_lottie() 0354 { 0355 var arr = {}; 0356 if ( this.colors !== null ) 0357 arr["k"] = value_to_lottie(this.colors); 0358 if ( this.count !== null ) 0359 arr["p"] = value_to_lottie(this.count); 0360 return arr; 0361 } 0362 0363 static from_lottie(arr) 0364 { 0365 var obj = new GradientColors(); 0366 if ( arr["k"] !== undefined ) 0367 obj.colors = value_from_lottie(arr["k"]); 0368 if ( arr["p"] !== undefined ) 0369 obj.count = value_from_lottie(arr["p"]); 0370 return obj; 0371 } 0372 } 0373