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


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


point()是另一种绘图函数,并且最简单。 point()函数本质上在图像的特定点上绘制一个点。它只需要两个x,y参数作为点坐标。

用法:
wand.drawing.point(x, y)

参数:

参数 输入类型 描述
x numbers.Real 点的x坐标
y numbers.Real 点的y坐标
范例1:
# Import different modules of wand 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
  
# object for Drawing 
with Drawing() as draw:
    x = 100
    y = 100
    # draw point at (100, 100) using point() function 
    draw.point(x, y) 
  
    with Image(width = 200, height = 200,  
               background = Color('lightgreen')) as image:
  
        draw(image) 
        image.save(filename ="point.png")

输出:



范例2:

# Import different modules of wand 
from wand.image import Image 
from wand.drawing import Drawing 
from wand.color import Color 
import math 
  
with Drawing() as draw:
    for x in xrange(0, 200):
        y = math.tan(x) * 4
        # draw points at different locations using point() function 
        draw.point(x, y + 50) 
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image) 
        image.save(filename = "points.png")

输出:




相关用法


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