当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Wand circle()用法及代码示例


circle()函数是Wand中的另一个绘图函数。此方法用于在图像中绘制圆。它仅需要两个参数,即圆的原点和周长。

用法: wand.drawing.circle(origin, perimeter)

参数:

参数 输入类型 描述
origin (collections.abc.Sequence)或(实数,数字。实数) 表示圆的原点x和y的一对。
perimeter (collections.abc.Sequence)或(实数,数字。实数) 对,代表圆的周长x和y

范例1:

# Import required objects from wand modules 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
  
# generate object for wand.drawing 
with Drawing() as draw:
  
    # set stroke color 
    draw.stroke_color = Color('black') 
  
    # set width for stroke 
    draw.stroke_width = 1
  
    # fill white color in arc 
    draw.fill_color = Color('white') 
    origin = (100, 100) 
    perimeter = (50, 50) 
  
    # draw circle using circle() function 
    draw.circle(origin, perimeter)  
    with Image(width = 200, 
               height = 200, 
               background = Color('green')) as img:
  
        # draw shape on image using draw() function 
        draw.draw(img) 
        img.save(filename ='circle.png')

输出:



范例2:
输入图片:

# Import required objects from wand modules 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
  
# generate object for wand.drawing 
with Drawing() as draw:
    origin = (100, 100) 
    perimeter = (50, 50) 
  
    # set stroke color 
    draw.stroke_color = Color('black') 
  
    # set width for stroke 
    draw.stroke_width = 1
  
    # fill white color in arc 
    draw.fill_color = Color('white') 
  
    # draw bezier curve using bezier function 
    draw.circle(origin, perimeter) 
    with Image(filename ="gog.png") as img:
  
        # draw shape on image using draw() function 
        draw.draw(img) 
        img.save(filename ='circle2.png')

输出:




相关用法


注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 Wand circle() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。