本文整理匯總了Python中cairo.Context.transform方法的典型用法代碼示例。如果您正苦於以下問題:Python Context.transform方法的具體用法?Python Context.transform怎麽用?Python Context.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cairo.Context
的用法示例。
在下文中一共展示了Context.transform方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_draw
# 需要導入模塊: from cairo import Context [as 別名]
# 或者: from cairo.Context import transform [as 別名]
def on_draw(self, widget: Widget, context: cairo.Context):
for child in self.list:
if child.visible:
context.save()
context.transform(child.fromWidgetCoords)
if child.is_clip_set():
rectangle = child.clip_rectangle
context.rectangle(rectangle.start.x,rectangle.start.y,
rectangle.width,rectangle.height)
context.clip()
child.on_draw(self,context)
context.restore()
示例2: ImageSurface
# 需要導入模塊: from cairo import Context [as 別名]
# 或者: from cairo.Context import transform [as 別名]
face.set_char_size( 48*64 )
face.load_char('S')
slot = face.glyph
outline = slot.outline
points = numpy.array(outline.points, dtype=[('x',float), ('y',float)])
x, y = points['x'], points['y']
cbox = outline.get_cbox()
surface = ImageSurface(FORMAT_ARGB32,
(cbox.xMax - cbox.xMin)//4 + 20,
(cbox.yMax - cbox.yMin)//4 + 20)
ctx = Context(surface)
ctx.scale(0.25,0.25)
ctx.translate(-cbox.xMin + 40,-cbox.yMin + 40)
ctx.transform(Matrix(1,0,0,-1))
ctx.translate(0, -(cbox.yMax + cbox.yMin)) # difference!
Curve_Tag = [FT_Curve_Tag(tag) for tag in outline.tags]
start, end = 0, 0
VERTS, CODES = [], []
# Iterate over each contour
ctx.set_source_rgb(0.5,0.5,0.5)
for i in range(len(outline.contours)):
end = outline.contours[i]
ctx.move_to(outline.points[start][0],outline.points[start][1])
for j in range(start, end+1):
point = outline.points[j]