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


Python compat.nested函数代码示例

本文整理汇总了Python中wand.compat.nested函数的典型用法代码示例。如果您正苦于以下问题:Python nested函数的具体用法?Python nested怎么用?Python nested使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_draw_point

def test_draw_point():
    with nested(Color('#fff'), Color('#000')) as (white, black):
        with Image(width=5, height=5, background=white) as img:
            with Drawing() as draw:
                draw.stroke_color = black
                draw.point(2,2)
                draw.draw(img)
                assert img[2,2] == black
开发者ID:ybrs,项目名称:wand,代码行数:8,代码来源:drawing_test.py

示例2: test_draw_comment

def test_draw_comment():
    comment = 'pikachu\'s ghost'
    expected = '#pikachu\'s ghost\n'
    with nested(Image(width=1, height=1), Drawing()) as (img, draw):
        draw.comment(comment)
        draw(img)
        blob = img.make_blob(format="mvg")
        assert expected == text(blob)
开发者ID:ybrs,项目名称:wand,代码行数:8,代码来源:drawing_test.py

示例3: test_draw_matte

def test_draw_matte():
    with nested(Color('#fff'),
                Color('transparent')) as (white, transparent):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.fill_opacity = 0
                draw.matte(25,25,'floodfill')
                draw.draw(img)
                assert img[25,25] == transparent
开发者ID:ybrs,项目名称:wand,代码行数:9,代码来源:drawing_test.py

示例4: test_draw_color

def test_draw_color():
    with nested(Color('#fff'),
                Color('#000')) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.fill_color = black
                draw.color(25,25,'floodfill')
                draw.draw(img)
                assert img[25,25] == black
开发者ID:ybrs,项目名称:wand,代码行数:9,代码来源:drawing_test.py

示例5: test_draw_translate

def test_draw_translate():
    with nested(Color('#fff'),
                Color('#000')) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.stroke_color = black
                draw.translate(x=5, y=5)
                draw.line((3, 3), (35, 35))
                draw.draw(img)
                assert img[40,40] == black
开发者ID:ybrs,项目名称:wand,代码行数:10,代码来源:drawing_test.py

示例6: test_draw_skew

def test_draw_skew():
    with nested(Color('#fff'),
                Color('#000')) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.stroke_color = black
                draw.skew(x=11,y=-24)
                draw.line((3, 3), (35, 35))
                draw.draw(img)
                assert img[43,42] == black
开发者ID:ybrs,项目名称:wand,代码行数:10,代码来源:drawing_test.py

示例7: test_draw_circle

def test_draw_circle(fx_asset):
    with nested(Color('#fff'),
                Color('#000')) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.fill_color = black
                draw.circle((25, 25), # Origin
                            (40, 40)) # Perimeter
                draw.draw(img)
                assert img[5,5] == img[45,45] == white
                assert img[25,25] == black
开发者ID:ybrs,项目名称:wand,代码行数:11,代码来源:drawing_test.py

示例8: test_draw_affine

def test_draw_affine(display, fx_wand):
    with nested(Color('skyblue'),
                Color('black')) as (skyblue, black):
        with Image(width=100, height=100, background=skyblue) as img:
            img.format = 'png'
            fx_wand.affine([1.5, 0.5, 0, 1.5, 45, 25])
            fx_wand.rectangle(top=5,left=5, width=25, height=25)
            fx_wand.draw(img)
            display(img)
            assert img[25, 25] == skyblue
            assert img[75, 75] == black
开发者ID:ybrs,项目名称:wand,代码行数:11,代码来源:drawing_test.py

示例9: test_draw_polyline

def test_draw_polyline(fx_wand):
    with nested(Color('#fff'),
                Color('#f00'),
                Color('#00f')) as (white, red, blue):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.fill_color = blue
                draw.stroke_color = red
                draw.polyline([(10, 10), (40, 25), (10, 40)])
                draw.draw(img)
                assert img[10, 25] == img[25, 25] == blue
                assert img[35, 15] == img[35, 35] == white
开发者ID:CodeInSuits,项目名称:wand,代码行数:12,代码来源:drawing_test.py

示例10: test_composite

def test_composite(fx_wand):
    with nested(Color('#fff'),
                Color('#000')) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            fx_wand.fill_color = black
            fx_wand.stroke_color = black
            fx_wand.rectangle(25, 25, 49, 49)
            fx_wand.draw(img)
            fx_wand.composite("replace", 0, 0, 25, 25, img)
            fx_wand.draw(img)
            assert img[45,45] == img[20,20] == black
            assert img[45,20] == img[20,45] == white
开发者ID:ybrs,项目名称:wand,代码行数:12,代码来源:drawing_test.py

示例11: test_draw_scale

def test_draw_scale(display, fx_wand):
    with nested(Color("#fff"),
                Color("#000")) as (white, black):
        with Image(width=50, height=50, background=white) as img:
            fx_wand.fill_color = black
            fx_wand.scale(x=2.0, y=0.5)
            fx_wand.rectangle(top=5, left=5, width=20, height=20)
            fx_wand.draw(img)
            display(img)
            # if width was scaled up by 200%
            assert img[45,10] == black
            # if height was scaled down by 50%
            assert img[20,20] == white
开发者ID:ybrs,项目名称:wand,代码行数:13,代码来源:drawing_test.py

示例12: test_draw_rectangle_with_radius

def test_draw_rectangle_with_radius(kwargs, display, fx_wand):
    with nested(Color('#fff'),
                Color('#333'),
                Color('#ccc')) as (white, black, gray):
        with Image(width=50, height=50, background=white) as img:
            fx_wand.stroke_width = 2
            fx_wand.fill_color = black
            fx_wand.stroke_color = gray
            fx_wand.rectangle(left=10, top=10,
                              width=30, height=30, **dict(kwargs))
            fx_wand.draw(img)
            display(img)
            assert img[10, 10] == img[40, 40] == white
            assert img[26, 12] == img[26, 36] == black
开发者ID:ybrs,项目名称:wand,代码行数:14,代码来源:drawing_test.py

示例13: test_set_fill_pattern_url

def test_set_fill_pattern_url(display, fx_wand):
    with nested(Color("#fff"),
                Color("#0f0"),
                Color("#000")) as (white, green, black):
        with Image(width=50, height=50, background=white) as img:
            fx_wand.push_pattern('green_circle',0 , 0, 10, 10)
            fx_wand.fill_color = green
            fx_wand.stroke_color = black
            fx_wand.circle(origin=(5, 5), perimeter=(5, 0))
            fx_wand.pop_pattern()
            fx_wand.set_fill_pattern_url('#green_circle')
            fx_wand.rectangle(top=5, left=5, width=40, height=40)
            fx_wand.draw(img)
            display(img)
            assert img[25,25] == green
开发者ID:ybrs,项目名称:wand,代码行数:15,代码来源:drawing_test.py

示例14: test_draw_rectangle

def test_draw_rectangle(kwargs, display, fx_wand):
    with nested(Color('#fff'),
                Color('#333'),
                Color('#ccc')) as (white, black, gray):
        with Image(width=50, height=50, background=white) as img:
            fx_wand.stroke_width = 2
            fx_wand.fill_color = black
            fx_wand.stroke_color = gray
            fx_wand.rectangle(left=10, top=10, **dict(kwargs))
            fx_wand.draw(img)
            display(img)
            assert (img[7, 7] == img[7, 42] == img[42, 7] ==
                    img[42, 42] == img[0, 0] == img[49, 49] == white)
            assert (img[12, 12] == img[12, 38] == img[38, 12] ==
                    img[38, 38] == black)
开发者ID:ybrs,项目名称:wand,代码行数:15,代码来源:drawing_test.py

示例15: test_draw_arc

def test_draw_arc(fx_asset):
    with nested(Color('#fff'),
                Color('#f00'),
                Color('#000')) as (white, red, black):
        with Image(width=50, height=50, background=white) as img:
            with Drawing() as draw:
                draw.fill_color = red
                draw.stroke_color = black
                draw.arc((10, 10), # Start
                         (40, 40), # End
                         (-90, 90)) # Degree
                draw.draw(img)
                assert img[20,25] == white
                assert img[30,25] == red
                assert img[40,25] == black
开发者ID:ybrs,项目名称:wand,代码行数:15,代码来源:drawing_test.py


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