本文整理匯總了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
#.........這裏部分代碼省略.........