本文整理匯總了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