我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用cairo.LINE_JOIN_MITER。
def draw(self, cr, highlight_items=None): if highlight_items is None: highlight_items = () cr.set_source_rgba(0.0, 0.0, 0.0, 1.0) cr.set_line_cap(cairo.LINE_CAP_BUTT) cr.set_line_join(cairo.LINE_JOIN_MITER) for shape in self.shapes: shape.draw(cr) for edge in self.edges: edge.draw(cr, highlight=(edge in highlight_items)) for node in self.nodes: node.draw(cr, highlight=(node in highlight_items))
def text_path(context, font, size, text, debug=False): """Create a Pango text layout and return it as a Cairo path""" context.save() pg_layout = PangoCairo.create_layout(context) pg_context = pg_layout.get_context() font_options = cairo.FontOptions() font_options.set_antialias(cairo.ANTIALIAS_SUBPIXEL) PangoCairo.context_set_font_options(pg_context, font_options) font_descp = "{0} {1:d}".format(font, size) pg_layout.set_font_description(Pango.FontDescription(font_descp)) pg_layout.set_text(text, -1) # force length calculation PangoCairo.update_layout(context, pg_layout) # TODO watch out for ink & logical, need check extents = pg_layout.get_pixel_extents()[0] # TODO debug necessary? if debug: context.set_source_rgb(0, 0, 0) PangoCairo.show_layout(context, pg_layout) print("text_path: ({0}, {1}, {2}, {3})".format( extents.x, extents.y, extents.width, extents.height)) context.rectangle(extents.x, extents.y, extents.width, extents.height) context.set_line_width(1.0) context.set_line_join(cairo.LINE_JOIN_MITER) context.set_source_rgb(0, 0.8, 0) context.stroke() #PangoCairo.layout_path(context, pg_layout) PangoCairo.layout_line_path(context, pg_layout.get_line(0)) path = context.copy_path() # clear the path context.new_path() context.restore() return (path, extents, xheight(pg_layout).height)