本文整理汇总了Python中Transform.translate方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.translate方法的具体用法?Python Transform.translate怎么用?Python Transform.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Context
# 需要导入模块: import Transform [as 别名]
# 或者: from Transform import translate [as 别名]
class Context():
'''
The Box class is an abstraction to hold a Cairo surface, context and all
methods to access and manipulate it (the Nodebox language is
implemented here).
'''
inch = 72
cm = 28.3465
mm = 2.8346
RGB = "rgb"
HSB = "hsb"
CENTER = "center"
CORNER = "corner"
CORNERS = "corners"
DEFAULT_WIDTH = 200
DEFAULT_HEIGHT = 200
NORMAL = "1"
FORTYFIVE = "2"
#self.cairoContext = None
#self._ctx
def __init__(self):
self.cairoContext = None
self.RGB = "rgb"
self.HSB = "hsb"
self.CMYK = "cmyk"
self._colormode = self.RGB
self._fillState = 1
self._lineWidth = 1
self._autoclosepath = True
self._transform = Transform()
self._fontsize = 10
#self._color = Color()
def size(self, width, height):
self.width = width
self.height = height
def rect2(self, x, y, width, height, roundness=0.0, draw=True):
if roundness == 0:
p = BezierPath()
p.rect(x, y, width, height)
else:
curve = min(width*roundness, height*roundness)
p = self.BezierPath(**kwargs)
p.moveto(x, y+curve)
p.curveto(x, y, x, y, x+curve, y)
p.lineto(x+width-curve, y)
p.curveto(x+width, y, x+width, y, x+width, y+curve)
p.lineto(x+width, y+height-curve)
p.curveto(x+width, y+height, x+width, y+height, x+width-curve, y+height)
p.lineto(x+curve, y+height)
p.curveto(x, y+height, x, y+height, x, y+height-curve)
p.closepath()
def createGraphContext( self, wxPaintDCObject):
self.cairoContext = wx.lib.wxcairo.ContextFromDC(wxPaintDCObject)
return self.cairoContext
def getGraphContext( self):
return self.cairoContext
# version 0.00
def rect( self, x, y, width, height, roundness=0.0, draw=True):
'''Draws a rectangle with top left corner at (x,y)
The roundness variable sets rounded corners.
'''
# straight corners
if roundness == 0.0:
self.cairoContext.save ()
if self._transform.mode == CENTER:
self.cairoContext.translate( x + width/2., y + height/2.)
self.cairoContext.rotate( - self._transform.radians)
x0 = -width/2.
y0 = -height/2.
else:
x0 = x
y0 = y
self.cairoContext.rectangle( x0, y0, width, height)
self.cairoContext.set_line_width( self._lineWidth)
if self._fillState == 1:
self.cairoContext.fill()
self.cairoContext.restore ()
else:
self.cairoContext.save ()
if self._transform.mode == CENTER:
self.cairoContext.translate( x + width/2., y + height/2.)
self.cairoContext.rotate( - self._transform.radians)
x0 = -width/2.
y0 = -height/2.
else:
x0 = x
#.........这里部分代码省略.........