本文整理汇总了Python中cairo.Context.set_dash方法的典型用法代码示例。如果您正苦于以下问题:Python Context.set_dash方法的具体用法?Python Context.set_dash怎么用?Python Context.set_dash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo.Context
的用法示例。
在下文中一共展示了Context.set_dash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import set_dash [as 别名]
def main(marker, paper, format, bbox, emergency, place, recipient, sender, text, sender_is_recipient, map_href):
"""
"""
mark = Location(*marker)
handle, filename = mkstemp(prefix='safetymap-', suffix='.pdf')
close(handle)
if paper == 'a4':
surf = PDFSurface(filename, 210*ptpmm, 297*ptpmm)
elif paper == 'letter':
surf = PDFSurface(filename, 8.5*ptpin, 11*ptpin)
ctx = Context(surf)
ctx.scale(ptpmm, ptpmm)
set_font_face_from_file(ctx, 'assets/HelveticaNeue.ttc')
if paper == 'a4':
draw_a4_master(ctx, format, map_href)
ctx.translate(19, 24)
elif paper == 'letter':
draw_letter_master(ctx, format, map_href)
ctx.translate(21, 18)
ctx.set_line_width(.25 * mmppt)
ctx.set_source_rgb(*md_gray)
ctx.set_dash([3 * mmppt])
reps = {'4up': 4, '2up-fridge': 2, 'poster': 0}
if reps[format]:
card_img, mark_point = get_map_image(bbox, 84, 39, mark)
for i in range(reps[format]):
# dashed outlines
ctx.move_to(0, 61)
ctx.line_to(0, 0)
ctx.line_to(173, 0)
ctx.line_to(173, 61)
#ctx.move_to(86, 0)
#ctx.line_to(86, 61)
ctx.stroke()
# two card sides and contents
draw_card_left(ctx, recipient, sender, text, sender_is_recipient)
ctx.translate(86.5, 0)
draw_card_right(ctx, card_img, mark_point, emergency, place)
ctx.translate(-86.5, 61)
if format == '4up':
# bottom dashed outline
ctx.move_to(0, 0)
ctx.line_to(172, 0)
ctx.stroke()
elif format == '2up-fridge':
# prepare to draw sideways
ctx.translate(0, 122.5)
ctx.rotate(-pi/2)
ctx.rectangle(0, 0, 122.5, 173)
ctx.stroke()
poster_img, mark_point = get_map_image(bbox, 109, 77, mark)
draw_small_poster(ctx, poster_img, mark_point, emergency, place, recipient, sender, text, sender_is_recipient)
elif format == 'poster':
ctx.rectangle(0, 0, 173, 245)
ctx.stroke()
poster_img, mark_point = get_map_image(bbox, 153, 108, mark)
draw_large_poster(ctx, poster_img, mark_point, emergency, place, recipient, sender, text, sender_is_recipient)
surf.finish()
chmod(filename, 0644)
return filename