本文整理汇总了Python中cairo.Context.new_path方法的典型用法代码示例。如果您正苦于以下问题:Python Context.new_path方法的具体用法?Python Context.new_path怎么用?Python Context.new_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo.Context
的用法示例。
在下文中一共展示了Context.new_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_svg
# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import new_path [as 别名]
def export_svg(fn, paths, size, line_with=0.1, scale_factor=None):
from cairo import SVGSurface, Context
from numpy import array
from ddd import spatial_sort_2d as sort
if not scale_factor:
scale_factor = size
one = 1.0/size
s = SVGSurface(fn, size, size)
c = Context(s)
c.set_line_width(0.1)
paths = sort(paths)
for path in paths:
path *= scale_factor
c.new_path()
c.move_to(*path[0,:])
for p in path[1:]:
c.line_to(*p)
c.stroke()
c.save()
示例2: export_svg
# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import new_path [as 别名]
def export_svg(fn, paths, w, h, line_width=0.1):
from cairo import SVGSurface, Context
s = SVGSurface(fn, w, h)
c = Context(s)
c.set_line_width(line_width)
for path in paths:
c.new_path()
c.move_to(*path[0,:])
for p in path[1:]:
c.line_to(*p)
c.stroke()
c.save()
示例3: range
# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import new_path [as 别名]
ctx.move_to(outline.points[start][0],outline.points[start][1])
for j in range(start, end+1):
point = outline.points[j]
ctx.line_to(point[0],point[1])
#back to origin
ctx.line_to(outline.points[start][0], outline.points[start][1])
start = end+1
ctx.fill_preserve()
ctx.set_source_rgb(0,1,0)
ctx.stroke()
start, end = 0, 0
for i in range(len(outline.contours)):
end = outline.contours[i]
ctx.new_path()
ctx.set_source_rgb(0,0,1)
for j in range(start, end+1):
if ( Curve_Tag[j] == FT_Curve_Tag_On ):
point = outline.points[j]
ctx.move_to(point[0],point[1])
ctx.arc(point[0], point[1], 40, 0, 2 * math.pi)
ctx.fill()
ctx.new_path()
ctx.set_source_rgb(1,0,0)
for j in range(start, end+1):
if ( Curve_Tag[j] != FT_Curve_Tag_On ):
point = outline.points[j]
ctx.move_to(point[0],point[1])
ctx.arc(point[0], point[1], 10, 0, 2 * math.pi)