File indexing completed on 2025-01-19 03:59:59
0001 import { value_to_lottie, value_from_lottie, LottieObject } from '../base.js'; 0002 import { Chars, Asset } from './assets.js'; 0003 import { FontList } from './text.js'; 0004 import { Layer } from './layers.js'; 0005 0006 /*! 0007 Top level object, describing the animation 0008 0009 @see http://docs.aenhancers.com/items/compitem/ 0010 @todo rename to Composition? 0011 */ 0012 export class Animation extends LottieObject 0013 { 0014 tgs; 0015 version; 0016 frame_rate; 0017 in_point; 0018 out_point; 0019 width; 0020 height; 0021 name; 0022 threedimensional; 0023 assets; 0024 fonts; 0025 layers; 0026 chars; 0027 0028 constructor() 0029 { 0030 super(); 0031 this.tgs = 1; 0032 this.version = '5.5.2'; 0033 this.frame_rate = 60; 0034 this.in_point = 0; 0035 this.out_point = 60; 0036 this.width = 512; 0037 this.height = 512; 0038 this.name = null; 0039 this.threedimensional = false; 0040 this.assets = []; 0041 this.fonts = null; 0042 this.layers = []; 0043 this.chars = null; 0044 } 0045 0046 to_lottie() 0047 { 0048 var arr = {}; 0049 if ( this.tgs !== null ) 0050 arr["tgs"] = value_to_lottie(Number(this.tgs)); 0051 if ( this.version !== null ) 0052 arr["v"] = value_to_lottie(this.version); 0053 if ( this.frame_rate !== null ) 0054 arr["fr"] = value_to_lottie(this.frame_rate); 0055 if ( this.in_point !== null ) 0056 arr["ip"] = value_to_lottie(this.in_point); 0057 if ( this.out_point !== null ) 0058 arr["op"] = value_to_lottie(this.out_point); 0059 if ( this.width !== null ) 0060 arr["w"] = value_to_lottie(this.width); 0061 if ( this.height !== null ) 0062 arr["h"] = value_to_lottie(this.height); 0063 if ( this.name !== null ) 0064 arr["nm"] = value_to_lottie(this.name); 0065 if ( this.threedimensional !== null ) 0066 arr["ddd"] = value_to_lottie(Number(this.threedimensional)); 0067 if ( this.assets !== null ) 0068 arr["assets"] = value_to_lottie(this.assets); 0069 if ( this.fonts !== null ) 0070 arr["fonts"] = value_to_lottie(this.fonts); 0071 if ( this.layers !== null ) 0072 arr["layers"] = value_to_lottie(this.layers); 0073 if ( this.chars !== null ) 0074 arr["chars"] = value_to_lottie(this.chars); 0075 return arr; 0076 } 0077 0078 static from_lottie(arr) 0079 { 0080 var obj = new Animation(); 0081 if ( arr["tgs"] !== undefined ) 0082 obj.tgs = value_from_lottie(Boolean(arr["tgs"])); 0083 if ( arr["v"] !== undefined ) 0084 obj.version = value_from_lottie(arr["v"]); 0085 if ( arr["fr"] !== undefined ) 0086 obj.frame_rate = value_from_lottie(arr["fr"]); 0087 if ( arr["ip"] !== undefined ) 0088 obj.in_point = value_from_lottie(arr["ip"]); 0089 if ( arr["op"] !== undefined ) 0090 obj.out_point = value_from_lottie(arr["op"]); 0091 if ( arr["w"] !== undefined ) 0092 obj.width = value_from_lottie(arr["w"]); 0093 if ( arr["h"] !== undefined ) 0094 obj.height = value_from_lottie(arr["h"]); 0095 if ( arr["nm"] !== undefined ) 0096 obj.name = value_from_lottie(arr["nm"]); 0097 if ( arr["ddd"] !== undefined ) 0098 obj.threedimensional = value_from_lottie(Boolean(arr["ddd"])); 0099 if ( arr["assets"] !== undefined ) 0100 obj.assets = value_from_lottie(arr["assets"]); 0101 if ( arr["fonts"] !== undefined ) 0102 obj.fonts = value_from_lottie(arr["fonts"]); 0103 if ( arr["layers"] !== undefined ) 0104 obj.layers = value_from_lottie(arr["layers"]); 0105 if ( arr["chars"] !== undefined ) 0106 obj.chars = value_from_lottie(arr["chars"]); 0107 return obj; 0108 } 0109 } 0110