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