本文整理汇总了Python中cairocffi.LINE_CAP_ROUND属性的典型用法代码示例。如果您正苦于以下问题:Python cairocffi.LINE_CAP_ROUND属性的具体用法?Python cairocffi.LINE_CAP_ROUND怎么用?Python cairocffi.LINE_CAP_ROUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cairocffi
的用法示例。
在下文中一共展示了cairocffi.LINE_CAP_ROUND属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import LINE_CAP_ROUND [as 别名]
def main(hexagon_size, imgsize):
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, imgsize, imgsize)
ctx = cairo.Context(surface)
# we will put the center of the hexagon at the origin
a, b, c = hexagon_size
ctx.translate(imgsize / 2.0, imgsize / 2.0)
extent = max(c, a * HALFSQRT3, b * HALFSQRT3) + 1
ctx.scale(imgsize / (extent * 2.0), -imgsize / (extent * 2.0))
ctx.translate(-b * HALFSQRT3, -c / 2.0)
# paint background
ctx.set_source_rgb(1, 1, 1)
ctx.paint()
ctx.set_line_cap(cairo.LINE_CAP_ROUND)
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
T = LozengeTiling(hexagon_size)
sample = run_cftp(T)
for key, val in T.get_tiles(sample).items():
for verts in val:
A, B, C, D = square_to_hex(verts)
ctx.move_to(A[0], A[1])
ctx.line_to(B[0], B[1])
ctx.line_to(C[0], C[1])
ctx.line_to(D[0], D[1])
ctx.close_path()
if key == "T":
ctx.set_source_rgb(*TOP_COLOR)
elif key == "L":
ctx.set_source_rgb(*LEFT_COLOR)
else:
ctx.set_source_rgb(*RIGHT_COLOR)
ctx.fill_preserve()
ctx.set_line_width(LINE_WIDTH)
ctx.set_source_rgb(*EDGE_COLOR)
ctx.stroke()
surface.write_to_png("random_lozenge_tiling.png")
示例2: main
# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import LINE_CAP_ROUND [as 别名]
def main():
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)
ctx.set_line_cap(cairo.LINE_CAP_ROUND)
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
ctx.set_source_rgb(1, 1, 1)
ctx.paint()
fractal_tree(ctx, ITERATIONS, ROOT, TRUNK_LEN,
RATIO, THETA, ANGLE, PERTURB)
surface.write_to_png("random_fractal_tree.png")
示例3: render
# 需要导入模块: import cairocffi [as 别名]
# 或者: from cairocffi import LINE_CAP_ROUND [as 别名]
def render(self, scale=109, margin=1, line_width=0.35/25.4,
bounds=None, show_bounds=True):
if cairo is None:
raise Exception('Drawing.render() requires cairo')
bounds = bounds or self.bounds
x1, y1, x2, y2 = bounds
w = x2 - x1
h = y2 - y1
margin *= scale
width = int(scale * w + margin * 2)
height = int(scale * h + margin * 2)
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
dc = cairo.Context(surface)
dc.set_line_cap(cairo.LINE_CAP_ROUND)
dc.set_line_join(cairo.LINE_JOIN_ROUND)
dc.translate(margin, margin)
dc.scale(scale, scale)
dc.translate(-x1, -y1)
dc.set_source_rgb(1, 1, 1)
dc.paint()
if show_bounds:
dc.set_source_rgb(0.5, 0.5, 0.5)
dc.set_line_width(1 / scale)
dc.rectangle(x1, y1, w, h)
dc.stroke()
dc.set_source_rgb(0, 0, 0)
dc.set_line_width(line_width)
for path in self.paths:
dc.move_to(*path[0])
for x, y in path:
dc.line_to(x, y)
dc.stroke()
return surface