Changeset 82 for nodebox/trunk/src/DrawingPrimitives.py
- Timestamp:
- 02/12/07 00:35:23 (2 years ago)
- Files:
-
- 1 modified
-
nodebox/trunk/src/DrawingPrimitives.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nodebox/trunk/src/DrawingPrimitives.py
r80 r82 71 71 def __repr__(self): 72 72 return "Point(x=%s, y=%s)" % (self.x, self.y) 73 74 def __eq__(self, other): 75 return self.x == other.x and self.y == other.y 76 77 def __ne__(self, other): 78 return not self.__eq__(other) 73 79 74 80 class Grob(object): … … 268 274 import bezier 269 275 self.path = bezier.insert_point(self, t).path 276 self._segment_cache = None 270 277 271 278 class PathElement(object): 272 cmd = None273 x = 0274 y = 0275 ctrl1 = Point()276 ctrl2 = Point()277 278 279 def __init__(self, cmd=None, pts=None): 279 280 self.cmd = cmd … … 281 282 assert len(pts) == 1 282 283 self.x, self.y = pts[0] 284 self.ctrl1 = Point(pts[0]) 285 self.ctrl2 = Point(pts[0]) 283 286 elif cmd == LINETO: 284 287 assert len(pts) == 1 285 288 self.x, self.y = pts[0] 289 self.ctrl1 = Point(pts[0]) 290 self.ctrl2 = Point(pts[0]) 286 291 elif cmd == CURVETO: 287 292 assert len(pts) == 3 … … 291 296 elif cmd == CLOSE: 292 297 assert pts is None or len(pts) == 0 298 self.x = self.y = 0.0 299 self.ctrl1 = Point(0.0, 0.0) 300 self.ctrl2 = Point(0.0, 0.0) 301 else: 302 self.x = self.y = 0.0 303 self.ctrl1 = Point() 304 self.ctrl2 = Point() 305 #else: 306 # raise NodeBoxError, "PathElement: unknown command %s" % cmd 293 307 294 308 def __repr__(self): … … 298 312 return "PathElement(LINETO, ((%s, %s),))" % (self.x, self.y) 299 313 elif self.cmd == CURVETO: 300 return "PathElement( LINETO, ((%s, %s), (%s, %s), (%s, %s))" % \314 return "PathElement(CURVETO, ((%s, %s), (%s, %s), (%s, %s))" % \ 301 315 (self.ctrl1.x, self.ctrl1.y, self.ctrl2.x, self.ctrl2.y, self.x, self.y) 302 316 elif self.cmd == CLOSE: 303 317 return "PathElement(CLOSE)" 318 319 def __eq__(self, other): 320 if self.cmd != other.cmd: return False 321 return self.x == other.x and self.y == other.y \ 322 and self.ctrl1 == other.ctrl1 and self.ctrl2 == other.ctrl2 323 324 def __ne__(self, other): 325 return not self.__eq__(other) 304 326 305 327 class Rect(BezierPath):
