Skip to main content

decorators

                            
                              
                                import
                                
                                {
                                ...
                                }
                                
                                from
                                
                                "@motion-canvas/2d/lib/decorators"
                                ;
                                

Classes

  • FiltersSignalContext

Interfaces

  • PropertyMetadata

Type Aliases

CanvasStyleSignal

                            
                              
                                type 
                                CanvasStyleSignal
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                 = 
                                Signal
                                
                                  
                                    
                                      PossibleCanvasStyle
                                    
                                    
                                      CanvasStyle
                                    
                                    
                                      T
                                    
                                  
                                
                              
                              

Type Parameters


FiltersSignal

                            
                              
                                type 
                                FiltersSignal
                                
                                  
                                    
                                      TOwner
                                    
                                  
                                
                                 = 
                                
                                  
                                    
                                      Signal
                                      
                                        
                                          
                                            Filter
                                            []
                                          
                                          
                                            Filter
                                            []
                                          
                                          
                                            TOwner
                                          
                                          
                                            FiltersSignalContext
                                            
                                              
                                                
                                                  TOwner
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                    
                                      
                                        
                                          
                                            [
                                            K
                                             in 
                                            FilterName
                                            ]: 
                                            SimpleSignal
                                            
                                              
                                                
                                                  number
                                                
                                                
                                                  TOwner
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Type Parameters


Initializer

                            
                              
                                type 
                                Initializer
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                 = 
                                public 
                                
                                ()
                              
                              

Type Parameters


Vector2LengthSignal

                            
                              
                                type 
                                Vector2LengthSignal
                                
                                  
                                    
                                      TOwner
                                    
                                  
                                
                                 = 
                                
                                  
                                    
                                      Signal
                                      
                                        
                                          
                                            PossibleVector2
                                            
                                              
                                                
                                                  Length
                                                
                                              
                                            
                                          
                                          
                                            Vector2
                                          
                                          
                                            TOwner
                                          
                                        
                                      
                                    
                                    
                                      
                                        
                                          
                                            x
                                            : 
                                            Signal
                                            
                                              
                                                
                                                  Length
                                                
                                                
                                                  number
                                                
                                                
                                                  TOwner
                                                
                                              
                                            
                                          
                                          
                                            y
                                            : 
                                            Signal
                                            
                                              
                                                
                                                  Length
                                                
                                                
                                                  number
                                                
                                                
                                                  TOwner
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Type Parameters

Functions

addInitializer

                            
                              
                                public 
                                addInitializer
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      target
                                      : 
                                      any
                                    
                                    
                                      initializer
                                      : 
                                      Initializer
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                void
                              
                              

Type Parameters

Parameters


canvasStyleSignal

                            
                              
                                public 
                                canvasStyleSignal
                                (): 
                                PropertyDecorator
                              
                              

cloneable

                            
                              
                                public 
                                cloneable
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                       = 
                                      true
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create a cloneable property decorator.

This decorator specifies whether the property should be copied over whencloning the node.

By default, any property is cloneable.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : boolean = true

    Whether the property should be cloneable.


colorSignal

                            
                              
                                public 
                                colorSignal
                                (): 
                                PropertyDecorator
                              
                              

compound

                            
                              
                                public 
                                compound
                                
                                  
                                    
                                      entries
                                      : 
                                      Record
                                      
                                        
                                          
                                            string
                                          
                                          
                                            string
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create a compound property decorator.

This decorator turns a given property into a signal consisting of one or morenested signals.

Examples

Parameters

  • entries : Record string string

    A record mapping the property in the compound object to thecorresponding property on the owner node.


computed

                            
                              
                                public 
                                computed
                                (): 
                                MethodDecorator
                              
                              

Create a computed method decorator.

This decorator turns the given method into a computed value.See createComputed for more information.


defaultStyle

                            
                              
                                public 
                                defaultStyle
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      styleName
                                      : 
                                      string
                                    
                                    
                                      parse
                                      : 
                                      public 
                                      
                                      () = 
                                      ...
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Type Parameters

Parameters


filtersSignal

                            
                              
                                public 
                                filtersSignal
                                (): 
                                PropertyDecorator
                              
                              

getPropertiesOf

                            
                              
                                public 
                                getPropertiesOf
                                
                                  
                                    
                                      value
                                      : 
                                      any
                                    
                                  
                                
                                : 
                                Record
                                
                                  
                                    
                                      string
                                    
                                    
                                      PropertyMetadata
                                      
                                        
                                          
                                            any
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Parameters


getPropertyMeta

                            
                              
                                public 
                                getPropertyMeta
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      object
                                      : 
                                      any
                                    
                                    
                                      key
                                      : 
                                      
                                        
                                          
                                            string
                                          
                                          
                                            symbol
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                
                                  
                                    
                                      PropertyMetadata
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                    
                                      null
                                    
                                  
                                
                              
                              

Type Parameters

Parameters


getPropertyMetaOrCreate

                            
                              
                                public 
                                getPropertyMetaOrCreate
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      object
                                      : 
                                      any
                                    
                                    
                                      key
                                      : 
                                      
                                        
                                          
                                            string
                                          
                                          
                                            symbol
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                PropertyMetadata
                                
                                  
                                    
                                      T
                                    
                                  
                                
                              
                              

Type Parameters

Parameters


initial

                            
                              
                                public 
                                initial
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      T
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create an initial signal value decorator.

This decorator specifies the initial value of a property.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : T

    The initial value of the property.


initialize

                            
                              
                                public 
                                initialize
                                
                                  
                                    
                                      target
                                      : 
                                      any
                                    
                                    
                                      context
                                      ?: 
                                      any
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


initializeSignals

                            
                              
                                public 
                                initializeSignals
                                
                                  
                                    
                                      instance
                                      : 
                                      any
                                    
                                    
                                      props
                                      : 
                                      Record
                                      
                                        
                                          
                                            string
                                          
                                          
                                            any
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


inspectable

                            
                              
                                public 
                                inspectable
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                       = 
                                      true
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create an inspectable property decorator.

This decorator specifies whether the property should be visible in theinspector.

By default, any property is inspectable.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : boolean = true

    Whether the property should be inspectable.


interpolation

                            
                              
                                public 
                                interpolation
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      InterpolationFunction
                                      
                                        
                                          
                                            T
                                          
                                          
                                            any
                                            []
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create a signal interpolation function decorator.

This decorator specifies the interpolation function of a property.The interpolation function is used when tweening between different values.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : InterpolationFunction T any []

    The interpolation function for the property.


parser

                            
                              
                                public 
                                parser
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      public 
                                      
                                      ()
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create a signal parser decorator.

This decorator specifies the parser of a property.Instead of returning the raw value, its passed as the first parameter to theparser and the resulting value is returned.

If the wrapper class has a method called lerp it will be set as thedefault interpolation function for the property.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : public ()

    The wrapper class for the property.


signal

                            
                              
                                public 
                                signal
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                (): 
                                PropertyDecorator
                              
                              

Create a signal decorator.

This decorator turns the given property into a signal.

The class using this decorator can implement the following methods:

  • get[PropertyName] - A property getter.
  • get[PropertyName] - A property setter.
  • tween[PropertyName] - A tween provider.

Examples

Type Parameters


vector2Signal

                            
                              
                                public 
                                vector2Signal
                                
                                  
                                    
                                      prefix
                                      ?: 
                                      
                                        
                                          
                                            string
                                          
                                          
                                            Record
                                            
                                              
                                                
                                                  string
                                                
                                                
                                                  string
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Parameters

  • prefix ?: string Record string string

wrapper

                            
                              
                                public 
                                wrapper
                                
                                  
                                    
                                      T
                                    
                                  
                                
                                
                                  
                                    
                                      value
                                      : 
                                      
                                        
                                          ()
                                          
                                            
                                              
                                                
                                                  lerp
                                                  ?: 
                                                  InterpolationFunction
                                                  
                                                    
                                                      
                                                        T
                                                      
                                                      
                                                        any
                                                        []
                                                      
                                                    
                                                  
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                PropertyDecorator
                              
                              

Create a signal wrapper decorator.

This is a shortcut decorator for setting both the parser and interpolation .

The interpolation function will be set only if the wrapper class has a methodcalled lerp , which will be used as said function.

Must be specified before the signal decorator.

Examples

Type Parameters

Parameters

  • value : () lerp ?: InterpolationFunction T any []

    The wrapper class for the property.