view flax/Node.py @ 124:8de8a2f467db

The "T" function now creates TimedEvents with LinearBlenders for you The "T" function now creates TimedEvents with LinearBlenders for you (using the same LinearBlender). Thus, we don't need to specify linear anymore. The timeline seek bar was reading the length of track1 instead of the whole timeline. This is fixed.
author dmcc
date Fri, 13 Jun 2003 15:55:54 +0000
parents 490843093506
children 7ccf1d10804b
line wrap: on
line source

# super rough code

# The magic value
NoChange = "NoChange"

class NodeType:
    def __init__(self, iports=None, oports=None):
        make_attributes_from_args('iports', 'oports')
    def process(self):
        pass
        # TODO: handle NoChange stuff

class AddNode(NodeType):
    """Adds two nodes together"""
    def __init__(self):
        NodeType.__init__(self, iports={'in1' : Port, 'in2' : Port},
                                oports={'out1' : Port})
    def process(self, ports):
        ports.out1 = ports.in1 + ports.in2

class SumNode(NodeType):
    """Adds any number of nodes together"""
    def __init__(self, empty_val=0):
        NodeType.__init__(self, iports={'in1' : MultiPort},
                                oports={'out1' : Port})
        self.empty_val = 0
    def process(self, ports):
        val = self.empty_val
        for p in ports.in1:
            val += p

        ports.out1 = val

class FadeNode(NodeType):
    """Provides a UI scaler to let you fade a value"""
    def __init__(self):
        NodeType.__init__(self, iports={'in1' : Port, 
                                        'scale1' : Port},
                                oports={'out1' : Port},
    def process(self, ports):
        ports.out1 = ports.in1 * ports.scale1 

class FadeConstellation(Constellation):
    """This somehow describes the following:

    [      ]    [ UI.Scale ]
      |            |
      | in         | scale
      |      ____ /
      |      |
    [ FadeNode ]
      | 
      | out
      |
    [      ]

    Maybe this is a group (I like this more):

      |
      | in
      |                FadeGroup
   - - - - - - - - - - - - -- - -
  |   |                          |
      |          [ UI.Scale ]    
  |   |            |             |
      | in         | scale  
  |   |      ____ /              |
      |      |
  | [ FadeNode ]                 |
      | 
  |   | out                      |
      |                          
  \ - - - - - - - - - - - -- - - /
      |
      | out
      | 
    """