当前位置: 首页>>代码示例>>Python>>正文


Python cairo.LINE_JOIN_ROUND属性代码示例

本文整理汇总了Python中cairo.LINE_JOIN_ROUND属性的典型用法代码示例。如果您正苦于以下问题:Python cairo.LINE_JOIN_ROUND属性的具体用法?Python cairo.LINE_JOIN_ROUND怎么用?Python cairo.LINE_JOIN_ROUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在cairo的用法示例。


在下文中一共展示了cairo.LINE_JOIN_ROUND属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _BasicPolygon

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_ROUND [as 别名]
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() 
开发者ID:karimbahgat,项目名称:GeoVis,代码行数:24,代码来源:__init__.py

示例2: render

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_ROUND [as 别名]
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 
开发者ID:fogleman,项目名称:Tiling,代码行数:27,代码来源:tile.py

示例3: main

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_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") 
开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:41,代码来源:main.py

示例4: main

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_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") 
开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:12,代码来源:fractaltree.py

示例5: draw

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_ROUND [as 别名]
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() 
开发者ID:pychess,项目名称:pychess,代码行数:29,代码来源:ChainVBox.py

示例6: __drawArrow

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import LINE_JOIN_ROUND [as 别名]
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() 
开发者ID:pychess,项目名称:pychess,代码行数:43,代码来源:BoardView.py


注:本文中的cairo.LINE_JOIN_ROUND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。