Show
Ignore:
Timestamp:
02/15/07 21:44:23 (23 months ago)
Author:
fdb
Message:

Fix in points to divide points evenly (previously, it forgot the point at t=1.0)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • nodebox/trunk/src/DrawingPrimitives.py

    r88 r89  
    268268            raise NodeBoxError, "The given path is empty" 
    269269 
    270         delta = 1.0/amount 
     270        # The delta value is divided by amount - 1, because we also want the last point (t=1.0) 
     271        # If I wouldn't use amount - 1, I fall one point short of the end. 
     272        # E.g. if amount = 4, I want point at t 0.0, 0.33, 0.66 and 1.0, 
     273        # if amount = 2, I want point at t 0.0 and t 1.0 
     274        try: 
     275            delta = 1.0/(amount-1) 
     276        except ZeroDivisionError: 
     277            delta = 1.0 
     278 
    271279        for i in xrange(amount): 
    272280            yield self.point(delta*i)