當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。