📜  Python中的魔杖矩形()函数

📅  最后修改于: 2022-05-13 01:54:36.061000             🧑  作者: Mango

Python中的魔杖矩形()函数

rectangle()函数,顾名思义,该函数用于在Python中使用 wand.drawing 对象绘制圆。矩形接受许多参数,如左、上、右、下、宽度、高度等。

示例 #1:

# 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:
    draw.fill_color = Color('GREEN')
    draw.rectangle(left = 25, top = 50, 
                   right = 175, bottom = 150)
  
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image)
        image.save(filename = "rectangle.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:
    draw.fill_color = Color('GREEN')
    draw.rectangle(left = 25, top = 50, right = 175,
                          bottom = 150, radius = 25)
  
    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:
        draw(image)
        image.save(filename = "rectangle.png")

输出: