Changeset 683

Show
Ignore:
Timestamp:
09/03/03 13:46:21 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBRapier/RBRapier/Formats/SVG/RapierRenderItems.py

    r680 r683  
    8585 
    8686class Transform(Transformations2d.Composite): 
    87     viewport = (0., 0., 0., 0.
     87    viewport = ((0., 0.), (None, None)
    8888    def GetViewport(self): 
    8989        return self.viewport 
    9090    def SetViewport(self, pos, size): 
    91         self.viewport = pos[0], pos[1], size[0], size[1] 
     91        self.viewport = pos, size 
    9292 
    9393    def __mul__(self, other): 
     
    119119        if x or y: 
    120120            self.Add(Transformations2d.Translate((x,y))) 
    121             self.Add(Transformations2d.Rotate(angle, (x,y))) 
     121            self.Add(Transformations2d.Rotate(angle)) 
    122122            self.Add(Transformations2d.Translate((-x,-y))) 
    123123        else: 
     
    143143    def AddSVGTransforms(self, transforms): 
    144144        def AddTransforms(name, *args): 
    145             transformfn = getattr(self, name, None) 
     145            transformfn = getattr(self, name.lower(), None) 
    146146            if transformfn is not None: 
    147147                transformfn(*args) 
     
    567567    #~ SVG Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    568568 
    569     def SetPosition(self, position): 
    570         self.position = position 
     569    #def SetPosition(self, position): 
     570    #    self.position = position 
    571571    def SetDimensions(self, width, height): 
    572572        self.dimensions = width, height 
     
    597597            if self.dimensions != (None, None): 
    598598                uw, uh = self.dimensions 
    599             else: uw, uh = 2., 2
     599            else: uw, uh = 1., 1
    600600 
    601601            transform.matrix(2./uw,0,-1.-2.*ux/uw, 0., -2./uh, 1.+2.*uy/uh) 
    602602        else:  
    603603            transform = transform.copy() 
    604             ux, uy, uw, uh = transform.GetViewport() 
     604            (ux, uy), (uw, uh) = transform.GetViewport() 
    605605 
    606606            if self.position != (None, None): 
     
    616616            vy = vy or 0. 
    617617 
    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' 
    619620            nw = float(vw)/uw 
    620621            nh = float(vh)/uh 
     
    639640                sx, sy = uw/vw, uh/vh 
    640641 
    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 
    650654 
    651655            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 
    652665 
    653666        return GroupRenderItem._GetStyleAndTransform(self, style, transform) 
     
    810823            if windingrule is None: windingrule = FillRuleLookup[None] 
    811824 
    812             points = self.points[:] 
    813             if points[0] != points[-1]: 
    814                 points.append(points[0]) 
    815  
    816825            self.tesselator.open(windingrule=windingrule) 
    817             glmodedatalist = self.tesselator.tessellate([points]) 
     826            glmodedatalist = self.tesselator.tessellate([self.points]) 
    818827            self.tesselator.close() 
    819828            for glmode, fillpoints in glmodedatalist: 
     
    850859        if fillcolor is not None: 
    851860            self.tesselator.open(windingrule=windingrule) 
    852             glmodedatalist = self.tesselator.tessellate([points]) 
     861            glmodedatalist = self.tesselator.tessellate([self.points]) 
    853862            self.tesselator.close() 
    854863            for glmode, fillpoints in glmodedatalist: 
     
    861870        if strokecolor is not None: 
    862871            self.tesselator.open(windingrule=windingrule) 
    863             glmodedatalist = self.tesselator.tessellate([points]) 
     872            glmodedatalist = self.tesselator.tessellate([self.points]) 
    864873            self.tesselator.close() 
    865874            for glmode, strokepoints in glmodedatalist: