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


Python api.Draw类代码示例

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


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

示例1: test_composite_arg_gravity

 def test_composite_arg_gravity(self):
     base = Image((300, 200), 'green')
     layer = Image((150, 100), 'transparent')
     drawer = Draw()
     drawer.circle(50, 50, 20, 20)
     layer.draw(drawer)
     base.composite(layer, 'center', 'over')
     base.write('t.png')
开发者ID:suoinguon,项目名称:pgmagick,代码行数:8,代码来源:test_pgmagick_api.py

示例2: draw_rectangle

    def draw_rectangle(self, x, y, width, height):
        draw = Draw()
        draw.fill_opacity(0.0)
        draw.stroke_color('white')
        draw.stroke_width(1)

        draw.rectangle(x, y, x + width, y + height)
        self.image.draw(draw.drawer)
开发者ID:diogomonica,项目名称:thumbor,代码行数:8,代码来源:graphicsmagick.py

示例3: test_rotation

 def test_rotation(self):
     self.d.rectangle(150, 150, 200, 200)
     self.d.rotation(40)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.fill_opacity(0.8)
     self.d.rectangle(150, 150, 200, 200)
     self.d.rotation(20)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.fill_opacity(0.6)
     self.d.rectangle(150, 150, 200, 200)
     self.im.draw(self.d)
     self.im.write('t.png')
开发者ID:suoinguon,项目名称:pgmagick,代码行数:14,代码来源:test_pgmagick_api.py

示例4: test_skew

 def test_skew(self):
     self.d = Draw()
     self.d.fill_opacity(0.6)
     self.d.circle(50, 50, 50, 100)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.fill_opacity(0.6)
     self.d.circle(50, 50, 50, 100)
     self.d.skewx(40)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.fill_opacity(0.6)
     self.d.circle(50, 50, 50, 100)
     self.d.skewy(40)
     self.im.draw(self.d)
     self.im.write('t.png')
开发者ID:suoinguon,项目名称:pgmagick,代码行数:16,代码来源:test_pgmagick_api.py

示例5: test_scaling

 def test_scaling(self):
     self.d.scaling(0.4, 0.4)
     self.d.circle(150, 150, 150, 200)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.fill_opacity(0.6)
     self.d.circle(150, 150, 150, 200)
     self.im.draw(self.d)
     self.im.write('t.png')
开发者ID:suoinguon,项目名称:pgmagick,代码行数:9,代码来源:test_pgmagick_api.py

示例6: __create_arrow_bg

    def __create_arrow_bg( self, points, color ):
        """
        Create a draw of arrow background.
        """

        draw = Draw()
        draw.stroke_antialias( False )
        draw.polygon( points )
        draw.fill_color( color )

        return draw
开发者ID:SparrowJang,项目名称:icon_converter,代码行数:11,代码来源:adapter.py

示例7: arrow

    def arrow( self, background_color = "#FFFFFF", border_color = "#BBBBBB" ):
        """
        Draw a arrow at icon bottom.
        """
        img = self.get_api_image()

        width = img.width
        height = img.height
        center_x = width / 2
        arrow_half_width = int( center_x / 3 )

        arrow_height = int( height / 7 )

        bg_img = ApiImage(( width, height + arrow_height + 1 ),'transparent')

        #
        arrow_start_x = center_x - arrow_half_width
        arrow_end_x = center_x + arrow_half_width
        center_y = height + arrow_height

        arrow_bg_start_point = ( arrow_start_x, height -1 )
        arrow_bg_end_point = ( arrow_end_x, height - 1 )
        arrow_bg_center_point = ( center_x, height + arrow_height )
        
        draw = Draw()
        draw.composite( 0, 0, width, height, img.img )

        bg_img.draw( draw )

        points = ( arrow_bg_start_point, arrow_bg_end_point, arrow_bg_center_point, arrow_bg_start_point )

        bg_img.draw( self.__create_arrow_bg( points, background_color ) )

        bg_img.draw( self.__create_arrow_border( arrow_start_x, arrow_end_x, height, arrow_height, border_color ) )

        self.__apiImage = bg_img
开发者ID:SparrowJang,项目名称:icon_converter,代码行数:36,代码来源:adapter.py

示例8: test_miterlimit

 def test_miterlimit(self):
     self.d.miterlimit(0)
     self.d.stroke_color('black')
     self.d.stroke_width(3)
     self.d.line(10, 200, 100, 10)
     self.d.line(100, 10, 210, 200)
     self.im.draw(self.d)
     self.d = Draw()
     self.d.miterlimit(18)
     self.d.stroke_color('black')
     self.d.stroke_width(3)
     self.d.stroke_opacity(0.5)
     self.d.fill_opacity(0.5)
     self.d.line(210, 200, 300, 10)
     self.d.line(300, 10, 410, 200)
     self.im.draw(self.d)
     self.im.write('t.png')
开发者ID:suoinguon,项目名称:pgmagick,代码行数:17,代码来源:test_pgmagick_api.py

示例9: setUp

 def setUp(self):
     self.im = Image((600, 400), 'red')
     self.d = Draw()
开发者ID:suoinguon,项目名称:pgmagick,代码行数:3,代码来源:test_pgmagick_api.py

示例10: DrawTestCase

class DrawTestCase(unittest.TestCase):

    def setUp(self):
        self.im = Image((600, 400), 'red')
        self.d = Draw()

    def test_affine(self):
        self.d.affine(10, 10, 20, 20, 40, 40)
        self.im.draw(self.d.drawer)
        self.im.write('t.jpg')

    def test_arc(self):
        self.d.arc(30, 30, 40, 40, 40, 40)
        self.im.draw(self.d.drawer)
        self.im.write('t.jpg')

    def test_bezier(self):
        points = ((30, 30), (50, 75), (200, 100))
        self.d.bezier(points)
        self.im.draw(self.d.drawer)
        self.im.write('t.png')

    def test_circle(self):
        self.d.circle(40, 40, 50, 100)
        self.im.draw(self.d.drawer)
        self.im.write('t.png')

    def test_color(self):
        self.d.color(40, 40, 'point')
        self.im.draw(self.d.drawer)
        self.im.write('t.png')

    def test_composite(self):
        img1 = Image((20, 20), 'plasma:blue')
        self.d.composite(10, 10, 0, 0, img1)
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_draw_for_draw_class(self):
        self.d.color(40, 40, 'point')
        self.d.circle(100, 100, 50, 100)
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_ellipse(self):
        self.d.ellipse(150, 150, 120, 120, 0, 120)
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_fill_color(self):
        self.d.fill_color('#f09060')
        self.d.ellipse(150, 150, 120, 120, 0, 120)
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_fill_rule(self):
        self.d.fill_rule('evenodd')
        self.d.circle(150, 150, 50, 180)
        self.d.fill_rule('nonzero')
        self.d.circle(350, 150, 250, 180)
        self.im.draw(self.d.drawer)
        self.im.write('t.png')

    def test_fill_opacity(self):
        self.im = Image((600, 400), 'transparent')
        self.d.fill_color('red')
        self.d.fill_opacity(0.5)
        self.d.circle(150, 150, 50, 180)
        self.d.fill_color('green')
        self.d.fill_opacity(0.8)
        self.d.circle(160, 160, 50, 180)
        self.im.draw(self.d.drawer)
        self.im.write('t.png')

    def test_font_style_italic(self):
        self.d.font('vera.ttf', 'italic')
        self.d.text(30, 30, "hello pgmagick")
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_font_style_oblique(self):
        self.d.font('vera.ttf', 'oblique')
        self.d.text(30, 30, "hello pgmagick")
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_font_stretch_ultracondensed(self):
        self.d.font('vera.ttf', 'oblique', stretch='ultracondensed')
        self.d.text(30, 30, "hello pgmagick")
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_font_stretch_extraexpanded(self):
        self.d.font('vera.ttf', 'oblique', stretch='extraexpanded')
        self.d.text(30, 30, "hello pgmagick")
        self.im.draw(self.d)
        self.im.write('t.png')

    def test_font_weight100(self):
        self.d.font('vera.ttf', weight=100)
#.........这里部分代码省略.........
开发者ID:suoinguon,项目名称:pgmagick,代码行数:101,代码来源:test_pgmagick_api.py

示例11: __create_arrow_border

    def __create_arrow_border( self, start_x, end_x , y, arrow_height, color ):
        """
        Create a draw of arrow border.
        """

        center_x = ( start_x + end_x ) /2
        center_y = arrow_height + y

        arrow_border_draw = Draw()
        arrow_border_draw.stroke_color( color )
        arrow_border_draw.stroke_antialias( False )
        arrow_border_draw.line( start_x, y, center_x, center_y )
        arrow_border_draw.line( center_x, center_y, end_x, y )
        arrow_border_draw.stroke_width( 2 )

        return arrow_border_draw
开发者ID:SparrowJang,项目名称:icon_converter,代码行数:16,代码来源:adapter.py

示例12: test_round_rectangle

 def test_round_rectangle(self):
     self.d = Draw()
     self.d.round_rectangle(20, 20, 30, 30, 150, 150)
     self.img.draw(self.d)
     self.img.write('t.png')
开发者ID:hhatto,项目名称:pgmagick,代码行数:5,代码来源:test_pgmagick_api.py


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