• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python compat.nested函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_path_curve_to_quadratic_bezier

def test_path_curve_to_quadratic_bezier():
    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 = (draw.path_start()
                        .path_move(to=(0, 25), relative=True)
                        .path_curve_to_quadratic_bezier(to=(50, 25), control=(25, 50))
                        .path_curve_to_quadratic_bezier(to=(-20, -20), control=(-25, 0), relative=True)
                        .path_finish())
                draw.draw(img)
                assert img[30,5] == red
开发者ID:ybrs,项目名称:wand,代码行数:15,代码来源:drawing_test.py


示例17: test_draw_bezier

def test_draw_bezier(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.bezier([(10,10),
                             (10,40),
                             (40,10),
                             (40,40)])
                draw.draw(img)
                assert img[10,10] == img[25,25] == img[40,40] == red
                assert img[34,32] == img[15,18] == blue
                assert img[34,38] == img[15,12] == white
开发者ID:ybrs,项目名称:wand,代码行数:16,代码来源:drawing_test.py


示例18: test_path_curve

def test_path_curve():
    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 = (draw.path_start()
                        .path_move(to=(0,25), relative=True)
                        .path_curve(to=(25,25), controls=((0, 0), (25, 0)))
                        .path_curve(to=(25,0), controls=((0, 25), (25, 25)), relative=True)
                        .path_finish())
                draw.draw(img)
                assert img[25,25] == red
                assert img[35,35] == img[35,35] == blue
                assert img[35,15] == img[15,35] == white
开发者ID:ybrs,项目名称:wand,代码行数:17,代码来源:drawing_test.py


示例19: test_draw_path_elliptic_arc

def test_draw_path_elliptic_arc():
    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 = (draw.path_start()
                        .path_move(to=(25,0))
                        .path_elliptic_arc(to=(25, 50), radius=(15, 25))
                        .path_elliptic_arc(to=(0,-15), radius=(5, 5), clockwise=False, relative=True)
                        .path_close()
                        .path_finish())
                draw.draw(img)
                assert img[25,35] == img[25,20] == red
                assert img[15,25] == img[30,45] == blue
开发者ID:ybrs,项目名称:wand,代码行数:17,代码来源:drawing_test.py


示例20: test_path_curve_to_quadratic_bezier_smooth

def test_path_curve_to_quadratic_bezier_smooth():
    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 = (draw.path_start()
                        .path_curve_to_quadratic_bezier(to=(25, 25), control=(25, 25))
                        .path_curve_to_quadratic_bezier(to=( 10, -10), smooth=True, relative=True)
                        .path_curve_to_quadratic_bezier(to=( 35, 35), smooth=True, relative=False)
                        .path_curve_to_quadratic_bezier(to=(-10, -10), smooth=True, relative=True)
                        .path_finish())
                draw.draw(img)
                assert img[25,25] == red
                assert img[30,30] == blue
开发者ID:ybrs,项目名称:wand,代码行数:17,代码来源:drawing_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python image.Image类代码示例发布时间:2022-05-26
下一篇:
Python wallet.get_asset_definition函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap