Changeset 683
- Timestamp:
- 09/03/03 13:46:21 (5 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Formats/SVG/RapierRenderItems.py
r680 r683 85 85 86 86 class Transform(Transformations2d.Composite): 87 viewport = ( 0., 0., 0., 0.)87 viewport = ((0., 0.), (None, None)) 88 88 def GetViewport(self): 89 89 return self.viewport 90 90 def SetViewport(self, pos, size): 91 self.viewport = pos [0], pos[1], size[0], size[1]91 self.viewport = pos, size 92 92 93 93 def __mul__(self, other): … … 119 119 if x or y: 120 120 self.Add(Transformations2d.Translate((x,y))) 121 self.Add(Transformations2d.Rotate(angle , (x,y)))121 self.Add(Transformations2d.Rotate(angle)) 122 122 self.Add(Transformations2d.Translate((-x,-y))) 123 123 else: … … 143 143 def AddSVGTransforms(self, transforms): 144 144 def AddTransforms(name, *args): 145 transformfn = getattr(self, name , None)145 transformfn = getattr(self, name.lower(), None) 146 146 if transformfn is not None: 147 147 transformfn(*args) … … 567 567 #~ SVG Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 568 569 def SetPosition(self, position):570 self.position = position569 #def SetPosition(self, position): 570 # self.position = position 571 571 def SetDimensions(self, width, height): 572 572 self.dimensions = width, height … … 597 597 if self.dimensions != (None, None): 598 598 uw, uh = self.dimensions 599 else: uw, uh = 2., 2.599 else: uw, uh = 1., 1. 600 600 601 601 transform.matrix(2./uw,0,-1.-2.*ux/uw, 0., -2./uh, 1.+2.*uy/uh) 602 602 else: 603 603 transform = transform.copy() 604 ux, uy, uw, uh= transform.GetViewport()604 (ux, uy), (uw, uh) = transform.GetViewport() 605 605 606 606 if self.position != (None, None): … … 616 616 vy = vy or 0. 617 617 618 xalign, yalign, aligntype = [s and s.lower() or s for s in self.alignment] 618 xalign, yalign, aligntype = [(s or '').lower() for s in self.alignment] 619 xalign, yalign = xalign or 'xmid', yalign or 'ymid' 619 620 nw = float(vw)/uw 620 621 nh = float(vh)/uh … … 639 640 sx, sy = uw/vw, uh/vh 640 641 641 if xalign == 'xmin': tx = ux - sx*vx + 0. 642 elif xalign == 'xmid': tx = ux - sx*vx + 0.5*(uw-vw*sx) 643 elif xalign == 'xmax': tx = ux - sx*vx + (uw-vw*sx) 644 else: tx = ux - sx*vx + 0.5*(uw-vw*sx) 645 646 if yalign == 'ymin': ty = uy - sy*vy + 0. 647 elif yalign == 'ymid': ty = uy - sy*vy + 0.5*(uh-vh*sy) 648 elif yalign == 'ymax': ty = uy - sy*vy + (uh-vh*sy) 649 else: ty = uy - sy*vy + 0.5*(uh-vh*sy) 642 if aligntype in ['meet', 'slice']: 643 if xalign == 'xmin': tx = ux - sx*vx + 0. 644 elif xalign == 'xmid': tx = ux - sx*vx + 0.5*(uw-vw*sx) 645 elif xalign == 'xmax': tx = ux - sx*vx + (uw-vw*sx) 646 else: assert False 647 648 if yalign == 'ymin': ty = uy - sy*vy + 0. 649 elif yalign == 'ymid': ty = uy - sy*vy + 0.5*(uh-vh*sy) 650 elif yalign == 'ymax': ty = uy - sy*vy + (uh-vh*sy) 651 else: assert False 652 else: 653 tx, ty = ux, uy 650 654 651 655 transform.matrix(sx, 0., tx, 0., sy, ty) 656 657 #print 658 #print "align", (xalign, yalign, aligntype) 659 #print "view:", vx, vy, vw, vh 660 #print "user:", ux, uy, uw, uh 661 #print "X:", sx, tx 662 #print "Y:", sy, ty 663 #print transform 664 #print 652 665 653 666 return GroupRenderItem._GetStyleAndTransform(self, style, transform) … … 810 823 if windingrule is None: windingrule = FillRuleLookup[None] 811 824 812 points = self.points[:]813 if points[0] != points[-1]:814 points.append(points[0])815 816 825 self.tesselator.open(windingrule=windingrule) 817 glmodedatalist = self.tesselator.tessellate([ points])826 glmodedatalist = self.tesselator.tessellate([self.points]) 818 827 self.tesselator.close() 819 828 for glmode, fillpoints in glmodedatalist: … … 850 859 if fillcolor is not None: 851 860 self.tesselator.open(windingrule=windingrule) 852 glmodedatalist = self.tesselator.tessellate([ points])861 glmodedatalist = self.tesselator.tessellate([self.points]) 853 862 self.tesselator.close() 854 863 for glmode, fillpoints in glmodedatalist: … … 861 870 if strokecolor is not None: 862 871 self.tesselator.open(windingrule=windingrule) 863 glmodedatalist = self.tesselator.tessellate([ points])872 glmodedatalist = self.tesselator.tessellate([self.points]) 864 873 self.tesselator.close() 865 874 for glmode, strokepoints in glmodedatalist:
