Python cairo.LINE_JOIN_ROUND Examples
The following are 6
code examples of cairo.LINE_JOIN_ROUND().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cairo
, or try the search function
.
Example #1
Source File: __init__.py From GeoVis with MIT License | 6 votes |
def _BasicPolygon(self, coords, options): """ Draw polygon with color fill """ if len(coords) >= 3: #define outline symbolics outlinecolor = self.__hex_to_rgb(options["outlinecolor"]) self.drawer.set_source_rgb(*outlinecolor) # Solid color self.drawer.set_line_width(options["outlinewidth"]) #...self.drawer.set_line_join(cairo.LINE_JOIN_ROUND) #first starting point xy = coords[0] self.drawer.move_to(*xy) #then add path for each new vertex for xy in coords[1:]: self.drawer.line_to(*xy) self.drawer.close_path() self.drawer.stroke_preserve() #then fill insides fillcolor = self.__hex_to_rgb(options["fillcolor"]) self.drawer.set_source_rgb(*fillcolor) self.drawer.fill()
Example #2
Source File: tile.py From Tiling with MIT License | 6 votes |
def render( self, dual=False, background_color=BACKGROUND_COLOR, margin=MARGIN, show_labels=SHOW_LABELS, line_width=LINE_WIDTH): surface = cairo.ImageSurface( cairo.FORMAT_RGB24, self.width, self.height) dc = cairo.Context(surface) dc.set_line_cap(cairo.LINE_CAP_ROUND) dc.set_line_join(cairo.LINE_JOIN_ROUND) dc.set_line_width(line_width) dc.set_font_size(18.0 / self.scale) dc.translate(self.width / 2, self.height / 2) dc.scale(self.scale, self.scale) dc.set_source_rgb(*color(background_color)) dc.paint() shapes = self.dual() if dual else self.lookup.values() if show_labels: for shape in shapes: shape.render_edge_labels(dc, margin - 0.25) for shape in shapes: shape.render(dc, margin) if show_labels: for index, shape in enumerate(self.shapes): if shape in shapes: shape.render_label(dc, index) return surface
Example #3
Source File: main.py From pywonderland with MIT License | 5 votes |
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")
Example #4
Source File: fractaltree.py From pywonderland with MIT License | 5 votes |
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")
Example #5
Source File: ChainVBox.py From pychess with GNU General Public License v3.0 | 5 votes |
def draw(self, context): allocation = self.get_allocation() x_loc = allocation.x y_loc = allocation.y width = allocation.width - 1 height = allocation.height context.set_source_rgb(.2, .2, .2) # context.rectangle(0, 0, width, height) # context.fill() context.move_to( self.__toAHalf(x_loc + width / 2.) - LONG_LINE, self.__toAHalf(y_loc + height / 2.)) context.line_to( self.__toAHalf(x_loc + width / 2.), self.__toAHalf(y_loc + height / 2.)) if self.position == CHAIN_TOP: context.line_to( self.__toAHalf(x_loc + width / 2.), self.__toAHalf(float(y_loc + height))) else: context.line_to( self.__toAHalf(x_loc + width / 2.), self.__toAHalf(y_loc + 0.)) context.set_line_width(1.0) context.set_line_cap(cairo.LINE_CAP_ROUND) context.set_line_join(cairo.LINE_JOIN_ROUND) context.stroke()
Example #6
Source File: BoardView.py From pychess with GNU General Public License v3.0 | 5 votes |
def __drawArrow(self, context, cords, aw, ahw, ahh, asw, fillc, strkc): context.save() lvx = cords[1].x - cords[0].x lvy = cords[0].y - cords[1].y hypotenuse = float((lvx ** 2 + lvy ** 2) ** .5) vec_x = lvx / hypotenuse vec_y = lvy / hypotenuse v1x = -vec_y v1y = vec_x rectangle = self.cord2Rect(cords[0]) px_loc = rectangle[0] + rectangle[2] / 2.0 py_loc = rectangle[1] + rectangle[2] / 2.0 ax_loc = v1x * rectangle[2] * aw / 2 ay_loc = v1y * rectangle[2] * aw / 2 context.move_to(px_loc + ax_loc, py_loc + ay_loc) p1x = px_loc + (lvx - vec_x * ahh) * rectangle[2] p1y = py_loc + (lvy - vec_y * ahh) * rectangle[2] context.line_to(p1x + ax_loc, p1y + ay_loc) lax = v1x * rectangle[2] * ahw / 2 lay = v1y * rectangle[2] * ahw / 2 context.line_to(p1x + lax, p1y + lay) context.line_to(px_loc + lvx * rectangle[2], py_loc + lvy * rectangle[2]) context.line_to(p1x - lax, p1y - lay) context.line_to(p1x - ax_loc, p1y - ay_loc) context.line_to(px_loc - ax_loc, py_loc - ay_loc) context.close_path() context.set_source_rgba(*fillc) context.fill_preserve() context.set_line_join(cairo.LINE_JOIN_ROUND) context.set_line_width(asw * rectangle[2]) context.set_source_rgba(*strkc) context.stroke() context.restore()