Changeset 691

Show
Ignore:
Timestamp:
09/05/03 17:58:19 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

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

    r686 r691  
    683683            xalign, yalign, aligntype = [(s or '').lower() for s in self.alignment] 
    684684            xalign, yalign = xalign or 'xmid', yalign or 'ymid' 
    685             nw, nh = float(vw)/uw, float(vh)/u
     685            nw, nh = float(uw)/vw, float(uh)/v
    686686 
    687687            if aligntype == 'meet': # scale by larger dimension 
    688                 if nh > nw: # height is greater -- scale by height 
     688                if nh < nw: # height is greater -- scale by height 
    689689                    sx = sy = uh/vh 
    690690                else: # width is greater -- scale by width 
    691691                    sx = sy = uw/vw 
    692692            elif aligntype == 'slice': # scale by smaller dimension 
    693                 if nh < nw: # width is greater -- scale by height 
     693                if nh > nw: # width is greater -- scale by height 
    694694                    sx = sy = uh/vh 
    695695                else: # height is greater -- scale by width 
  • trunk/RBRapier/RBRapier/Tools/Projections.py

    r658 r691  
    124124    def SetAspectRatio(self, value, byWidth=None): 
    125125        if byWidth is None: 
    126             byWidth = value < 1 #self.Width < self.Height 
     126            byWidth = value < 1 
    127127        if byWidth: 
    128128            self.Width = self.Height / float(value) 
     
    130130            self.Height = self.Width * float(value) 
    131131    AspectRatio = property(GetAspectRatio, SetAspectRatio) 
     132 
     133    def SetDimensionsAspectRatio(self, width, height, aspectYX=1., largest=True): 
     134        width, height, aspectYX = map(float, (width, height, aspectYX)) 
     135        if largest: # scale by larger dimension 
     136            if height/width > aspectYX: # height is greater -- scale width 
     137                width = height/aspectYX 
     138            else: # width is greater -- scale height 
     139                height = width*aspectYX 
     140        else: # scale by smaller dimension 
     141            if height/width < aspectYX: # width is greater -- scale height 
     142                width = height/aspectYX 
     143            else: # height is greater -- scale width 
     144                height = width*aspectYX 
     145        self.Width, self.Height = width, height 
     146        return width, height 
    132147 
    133148    def _asTuple(self): 
  • trunk/RBRapier/RBRapier/Tools/RectangleBase.py

    r658 r691  
    6868    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    6969 
    70     def _getX1(self): return self.Rectangle[0] 
    71     def _setX1(self, X): self.Rectangle[0] = X 
    72     X = X1 = property(_getX1, _setX1) 
    73     def _getX2(self): return self.Rectangle[0] + self.Rectangle[2] 
    74     def _setX2(self, X): self.Rectangle[0] = X - self.Rectangle[2] 
    75     X2 = property(_getX2, _setX2) 
    76     def _getWidth(self): return self.Rectangle[2] 
    77     def _setWidth(self, width):  self.Rectangle[2] = width 
    78     Width = property(_getWidth, _setWidth) 
     70    def GetX1(self): return self.Rectangle[0] 
     71    def SetX1(self, X): self.Rectangle[0] = X 
     72    X = X1 = property(GetX1, SetX1) 
     73    def GetX2(self): return self.Rectangle[0] + self.Rectangle[2] 
     74    def SetX2(self, X): self.Rectangle[0] = X - self.Rectangle[2] 
     75    X2 = property(GetX2, SetX2) 
     76    def GetWidth(self): return self.Rectangle[2] 
     77    def SetWidth(self, width):  self.Rectangle[2] = width 
     78    Width = property(GetWidth, SetWidth) 
    7979 
    80     def _getY1(self): return self.Rectangle[1] 
    81     def _setY1(self, Y): self.Rectangle[1] = Y 
    82     Y = Y1 = property(_getY1, _setY1) 
    83     def _getY2(self): return self.Rectangle[1] + self.Rectangle[3] 
    84     def _setY2(self, Y): self.Rectangle[1] = Y - self.Rectangle[3] 
    85     Y2 = property(_getY2, _setY2) 
    86     def _getHeight(self): return self.Rectangle[3] 
    87     def _setHeight(self, height):  self.Rectangle[3] = height 
    88     Height = property(_getHeight, _setHeight) 
     80    def GetY1(self): return self.Rectangle[1] 
     81    def SetY1(self, Y): self.Rectangle[1] = Y 
     82    Y = Y1 = property(GetY1, SetY1) 
     83    def GetY2(self): return self.Rectangle[1] + self.Rectangle[3] 
     84    def SetY2(self, Y): self.Rectangle[1] = Y - self.Rectangle[3] 
     85    Y2 = property(GetY2, SetY2) 
     86    def GetHeight(self): return self.Rectangle[3] 
     87    def SetHeight(self, height):  self.Rectangle[3] = height 
     88    Height = property(GetHeight, SetHeight) 
    8989 
    90     def _getPosition(self): return self.Rectangle[0:2] 
    91     def _setPosition(self, position): self.Rectangle[0:2] = self.Rectangle.__class__(position) 
    92     Position = Position1 = property(_getPosition, _setPosition) 
     90    def GetPosition(self): return self.Rectangle[0:2] 
     91    def SetPosition(self, position): self.Rectangle[0:2] = self.Rectangle.__class__(position) 
     92    Position = Position1 = property(GetPosition, SetPosition) 
    9393 
    94     def _getPosition2(self): return map(operator.add, self.Rectangle[0:2], self.Rectangle[2:4]) 
    95     def _setPosition2(self, position): self.Rectangle[2:4] = map(operator.sub, self.Rectangle.__class__(position), self.Rectangle[0:2]) 
    96     Position2 = property(_getPosition2, _setPosition2) 
     94    def GetPosition2(self): return map(operator.add, self.Rectangle[0:2], self.Rectangle[2:4]) 
     95    def SetPosition2(self, position): self.Rectangle[2:4] = map(operator.sub, self.Rectangle.__class__(position), self.Rectangle[0:2]) 
     96    Position2 = property(GetPosition2, SetPosition2) 
    9797 
    98     def _getDimension(self): return self.Rectangle[2:4] 
    99     def _setDimension(self, dimension): self.Rectangle[2:4] = self.Rectangle.__class__(dimension) 
    100     Dimension = property(_getDimension, _setDimension) 
     98    def GetDimension(self): return self.Rectangle[2:4] 
     99    def SetDimension(self, dimension): self.Rectangle[2:4] = self.Rectangle.__class__(dimension) 
     100    Dimension = property(GetDimension, SetDimension) 
    101101 
    102     def _getAspectRatio(self): return float(self.Rectangle[3]) / float(self.Rectangle[2]) 
    103     AspectRatio = property(_getAspectRatio) 
     102    def GetAspectRatio(self): return float(self.Rectangle[3]) / float(self.Rectangle[2]) 
     103    AspectRatio = property(GetAspectRatio) 
    104104 
    105105    def SetRectangle(self, *args):  
  • trunk/RBRapier/demo/Cube/cubescene.py

    r666 r691  
    7676    def Render(self, glviewsetup, canvas): 
    7777        self.viewport.SetRectangle(canvas.GetClientRect().asTuple()) 
    78         self.projection.Dimensions = 2, 2, 2 
    79         self.projection.AspectRatio = self.viewport.AspectRatio 
     78        self.projection.SetDimensionsAspectRatio(2., 2., self.viewport.GetAspectRatio()) 
    8079        self.root.Execute(None) 
    8180 
  • trunk/RBRapier/demo/SVG/display.py

    r685 r691  
    140140    def Render(self, subject, canvas): 
    141141        self.viewport.SetRectangle(canvas.GetClientRect().asTuple()) 
    142         self.projection.Dimensions = 2, 2, 2 
    143         self.projection.AspectRatio = self.viewport.AspectRatio 
     142        self.projection.SetDimensionsAspectRatio(2., 2., self.viewport.GetAspectRatio()) 
    144143        self.root.Execute(None) 
    145144