bezier()是Wand中的另一个绘图函数。此方法用于绘制贝塞尔曲线。它需要四个点才能确定贝塞尔曲线。极限点定义曲线的起点和终点,而在两个点之间则用于控制曲线。
用法: wand.drawing.bezier(points)
参数:
参数 | 输入类型 | 描述 |
---|---|---|
points | list | 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
# points list to determine curve
points = [(40, 10), # Start point
(20, 50), # First control
(90, 10), # Second control
(70, 40)] # End point
# fill white color in arc
draw.fill_color = Color('white')
# draw bezier curve using bezier function
draw.bezier(points)
with Image(width = 100,
height = 100,
background = Color('green')) as img:
# draw shape on image using draw() function
draw.draw(img)
img.save(filename ='bezier.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:
points = [(20, 100), # Start point
(50, 10), # First control
(50, 90), # Second control
(180, 100)]
# 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
# From bottom left around to top right
draw.bezier(points)
with Image(filename ="gog.png") as img:
# draw shape on image using draw() function
draw.draw(img)
img.save(filename ='bezier2.png')
输出:
相关用法
- Python Wand bezier()用法及代码示例
- Python bokeh.plotting.figure.bezier()用法及代码示例
- Python Wand function()用法及代码示例
- Python Wand gaussian_blur()用法及代码示例
- Python Wand transform()用法及代码示例
- Python Wand crop()用法及代码示例
- Python Wand rotational_blur()用法及代码示例
- Python Wand Image()用法及代码示例
- Python Wand shade()用法及代码示例
- Python Wand sharpen()用法及代码示例
- Python Wand adaptive_sharpen()用法及代码示例
- Python Wand noise()用法及代码示例
- Python Wand blue_shift()用法及代码示例
- Python Wand color_matrix()用法及代码示例
- Python Wand unsharp_mask()用法及代码示例
注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 Wand bezier() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。