Changeset - 490843093506
[Not reviewed]
default
0 2 0
dmcc - 22 years ago 2003-06-10 10:31:57

all of this stuff is super rough and not well thought out yet.
all of this stuff is super rough and not well thought out yet.
i'm just checking in so we have some stuff to work with for the
sprint tonight.
2 files changed with 26 insertions and 122 deletions:
0 comments (0 inline, 0 general)
flax/Node.py
Show inline comments
 
@@ -3,13 +3,13 @@
 
# The magic value
 
NoChange = "NoChange"
 

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

	
 
class AddNode(NodeType):
 
    """Adds two nodes together"""
 
    def __init__(self):
 
@@ -31,16 +31,16 @@ class SumNode(NodeType):
 

	
 
        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, iports, oports):
 
        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 ]
 
@@ -72,109 +72,6 @@ class FadeConstellation(Constellation):
 
      |                          
 
  \ - - - - - - - - - - - -- - - /
 
      |
 
      | out
 
      | 
 
    """
 

	
 
Persistence
 
node instance saves:
 
    node name, id, and such
 
    input ports:
 
        any port details
 
        what the port connects to
 
    values:
 
        maybe UI.Scale level
 
        maybe group contents
 

	
 

	
 
p=InputPort(node=self,minconns=1,maxconns=2) # an input port to this node
 
p.connect(othernode)
 
print p.connections()
 
p.connect(yetanother)
 

	
 
op=OutputPort(node=self) # an output port
 
print op.connections() # lists all the nodes that call us an input node
 
op.connect(n) # calls n.connect(self)
 

	
 

	
 

	
 
        
 
Ports
 
    Port: "scalar"
 
    MultiPort: "array of Port"
 
    ^ all wrong
 

	
 
    Ports II:
 
        min/max number of connections
 
           (failure to fit these numbers means port is "deactivated")
 
        "Normal" ports are min=1, max=1
 
        "Multiports" are min=0, max=None
 
        "Binary" ports are min=2, max=2
 
        oh yeah, there are two totally different types of ports
 

	
 
        Input ports: min/max numbers of connections
 
           store current connections
 
        Output ports: nothing
 
           store nothing!
 

	
 
fake node persistence for subtract node
 

	
 
<!-- "my subtract" is a unique id -->
 
<!-- drew: there is no such thing as a subtract group -->
 
<node name="my subtract" type="math.Add">
 
  <inputs>
 
    <port name="in1">
 
       <noderef name="node I"/>
 
       <noderef name="node II"/>
 
    </port>
 
  </inputs>
 
  <state>
 
  </state>
 
    
 
</node>
 

	
 

	
 
<node name="the group" type="group">
 

	
 
  <!-- all of the port names of the group are being made up right
 
  here- a group has no preset inputs or outputs-->
 

	
 
  <inputs>
 
    <port name="group-in 1">
 
      <noderef name="node5"/>
 
      <noderef name="node6"/>
 
    </port>
 
  </inputs>
 
  
 
  <state>  
 
    <children>
 
      <noderef name="node3">
 
        <connect localPort="in1" groupPort="group-in1"/>
 
      </noderef>
 
      <noderef name="node4">
 
        <connect localPort="in1" groupPort="group-in1"/>
 
        <connect localPort="out1" groupPort="theoutput"/>
 
      </noderef>
 
    </children>
 

	
 
  </state>  
 
</node>
 

	
 
<node name="preset value" type="source.Scalar">
 
  <!-- no inputs, node has output only -->
 
  <state>
 
    <value>8.3</value>
 

	
 
    <minvalue>0</minvalue>
 
    <maxvalue>100</maxvalue>
 
    
 
    <gui>
 
      <slider res=".1" height="200" bgcolor="red"/>
 
      <priority>very high</priority>
 
      <xpos>395</xpos>
 
      <ypos>21</ypos>
 
    </gui>
 
    
 
  </state>
 

	
 
</node>
flax/Timeline.py
Show inline comments
 
from TLUtility import make_attributes_from_args, dict_scale, dict_max, \
 
    DummyClass, last_less_than, first_greater_than
 
from time import time
 
from __future__ import division # "I'm sending you back to future!"
 

	
 
"""
 
Changelog:
 
Fri May 16 15:17:34 PDT 2003
 
    Project started (roughly).
 

	
 
Mon May 19 17:56:24 PDT 2003
 
    Timeline is more or less working.  Still bugs with skipping
 
    FunctionFrames at random times.
 
Quote of the Build (from Ghostbusters II)
 
Dana:  Okay, but after dinner, I don't want you putting any of your old cheap 
 
       moves on me. 
 
Peter: Ohhhh no! I've got all NEW cheap moves.
 

	
 
Timeline idea
 
=============
 
 time    | 0   1   2   3   4   5   6
 
---------+-----------------------------
 
frame    | F       F           F
 
@@ -174,21 +171,23 @@ class BounceFunction(FunctionFrame):
 
        print "boing! new dir:", timeline.direction
 

	
 
# this too
 
class LoopFunction(FunctionFrame):
 
    def __call__(self, timeline, timedevent, node):
 
        timeline.set_time(0)
 
        print 'looped!'
 
        # print 'looped!'
 

	
 
class DoubleTimeFunction(FunctionFrame):
 
    def __call__(self, timeline, timedevent, node):
 
        timeline.set_rate(2 * timeline.rate)
 
        print 'doubled!', timeline.rate
 

	
 
class HalfTimeFunction(FunctionFrame):
 
    def __call__(self, timeline, timedevent, node):
 
        timeline.set_rate(0.5 * timeline.rate)
 
        print 'halved!', timeline.rate
 

	
 
class TimedEvent:
 
    """Container for a Frame which includes a time that it occurs at,
 
    and which blender occurs after it."""
 
    def __init__(self, time, frame, blender=None):
 
        make_attributes_from_args('time', 'frame')
 
@@ -323,12 +322,14 @@ class TimelineTrack:
 
    def get_range(self, i, j, direction=FORWARD):
 
        """Returns all events between i and j, exclusively.  If direction
 
        is FORWARD, j will be included.  If direction is BACKWARD, i will
 
        be included.  This is because this is used to find FunctionFrames
 
        and we assume that any function frames at the start point (which
 
        could be i or j) have been processed."""
 
        return [e for e in self.events if e >= i and e <= j]
 

	
 
        if direction == FORWARD:
 
            return [e for e in self.events if e > i and e <= j]
 
        else:
 
            return [e for e in self.events if e >= i and e < j]
 
    def __getitem__(self, key):
 
        """Returns the event at or after a specific time key.
 
@@ -413,32 +414,36 @@ class Timeline:
 
        # first, determine new time
 
        clock_time = time()
 
        if last_clock is None:
 
            last_clock = clock_time
 
        diff = clock_time - last_clock
 
        new_time = (self.direction * self.rate * diff) + last_time
 
        new_time = max(new_time, 0)
 
        new_time = min(new_time, self.length())
 
        
 
        # update the time
 
        self.last_clock_time = clock_time
 
        self.current_time = new_time
 
        
 
        # now, find out if we missed any functions
 
        if self.fn_track.has_events():
 
            lower_time, higher_time = last_time, new_time
 
            if lower_time == higher_time: print "zarg!"
 
            if lower_time > higher_time:
 
                lower_time, higher_time = higher_time, lower_time
 
            
 
            events_to_process = self.fn_track.get_range(lower_time, 
 
                higher_time, self.direction)
 
            
 
            for event in events_to_process:
 
                # they better be FunctionFrames
 
                event.frame(self, event, None) # the None should be a Node, 
 
                                               # but that part is coming later
 
        
 
        # now we make sure we're in bounds (we don't do this before, since it
 
        # can cause us to skip events that are at boundaries.
 
        self.current_time = max(self.current_time, 0)
 
        self.current_time = min(self.current_time, self.length())
 
    def reverse_direction(self):
 
        """Reverses the direction of play for this node"""
 
        self.direction = self.direction * -1
 
    def set_direction(self, direction):
 
        """Sets the direction of playback."""
 
        self.direction = direction
 
@@ -472,24 +477,26 @@ if __name__ == '__main__':
 
    track1 = TimelineTrack('lights',
 
        T(0, scene1, blender=linear),
 
        T(5, scene2, blender=quad),
 
        T(10, scene3, blender=smoove),
 
        T(15, scene2)) # last TimedEvent doesn't need a blender
 

	
 
    if 1:
 
    halver = HalfTimeFunction('1/2x')
 
    doubler = DoubleTimeFunction('2x')
 
    if 0:
 
        # bounce is semiworking
 
        bouncer = BounceFunction('boing')
 
        halver = HalfTimeFunction('1/2x')
 
        doubler = DoubleTimeFunction('2x')
 
        tl = Timeline([track1], [T(0, bouncer), 
 
                                 T(0, halver),
 
                                 T(15, bouncer),
 
                                 T(15, doubler)])
 
    else:
 
        looper = LoopFunction('loop1')
 
        tl = Timeline([track1], [T(14, looper)])
 
        tl = Timeline([track1], [T(0, doubler),
 
                                 T(5, halver),
 
                                 T(14, looper)])
 
    tl.play()
 

	
 
    import Tix
 
    root = Tix.Tk()
 
    colorscalesframe = Tix.Frame(root)
 
    scalevars = {}
0 comments (0 inline, 0 general)