@@ -26,6 +26,8 @@ export default class Shape {
2626 * @param {String } [options.background] Background color from {@link COLORS}
2727 * @param {String } [options.foreground] Foreground color from {@link COLORS}
2828 * @param {Object } [options.animation] Animation options for this shape
29+ * @param {String } [options.animation.name] Name of animation to play
30+ * @param {Object } [options.animation.options] Options for the specified animation
2931 */
3032 constructor ( options = { } ) {
3133 this . _options = options ;
@@ -275,13 +277,51 @@ export default class Shape {
275277 return this ;
276278 }
277279
280+ /**
281+ * Get animation name.
282+ *
283+ * @returns {String }
284+ */
285+ getAnimationName ( ) {
286+ return this . get ( 'animation.name' ) ;
287+ }
288+
289+ /**
290+ * Set animation name.
291+ *
292+ * @param {String } name
293+ * @returns {Shape }
294+ */
295+ setAnimationName ( name ) {
296+ return this . set ( 'animation.name' , name ) ;
297+ }
298+
299+ /**
300+ * Get animation options.
301+ *
302+ * @returns {Object }
303+ */
304+ getAnimationOptions ( ) {
305+ return this . get ( 'animation.options' ) ;
306+ }
307+
308+ /**
309+ * Set animation options.
310+ *
311+ * @param {Object } options
312+ * @returns {Shape }
313+ */
314+ setAnimationOptions ( options ) {
315+ return this . set ( 'animation.options' , options ) ;
316+ }
317+
278318 /**
279319 * Check if this shape is animated.
280320 *
281321 * @returns {Boolean }
282322 */
283323 isAnimated ( ) {
284- return ! ! this . get ( 'animation' ) ;
324+ return ! ! this . get ( 'animation' ) && ! ! this . get ( 'animation.name' ) ;
285325 }
286326
287327 /**
@@ -308,13 +348,16 @@ export default class Shape {
308348 text : this . getText ( ) ,
309349 width : this . getWidth ( ) ,
310350 height : this . getHeight ( ) ,
311- x : this . getPosition ( ) . x ,
312- y : this . getPosition ( ) . y ,
351+ x : this . getX ( ) ,
352+ y : this . getY ( ) ,
313353 alignX : this . getAlignX ( ) ,
314354 alignY : this . getAlignY ( ) ,
315355 background : this . getBackground ( ) ,
316356 foreground : this . getForeground ( ) ,
317- animation : this . getAnimation ( )
357+ animation : {
358+ name : this . getAnimationName ( ) ,
359+ options : this . getAnimationOptions ( )
360+ }
318361 }
319362 } ;
320363 }
0 commit comments