Wand ellipse() function in Python
Last Updated :
10 Mar, 2023
ellipse() function is used to draw an ellipse on the image. Just similar to drawing circle the ellipse() function requires two pairs of point that is, origin and a pair of (x, y) radius of the ellipse. To draw a partial ellipse, provide a pair of starting & ending degrees as the third parameter.
Syntax :
wand.drawing.ellipse(origin, radius, rotation)
Parameters :
Parameter |
Input Type |
Description |
origin |
(collections.abc.Sequence) – (numbers.Real, numbers.Real) |
pair which represents origin x and y of ellipse. |
radius |
(collections.abc.Sequence) – (numbers.Real, numbers.Real) |
pair which represents radius x and radius y of ellipse |
rotation |
(collections.abc.Sequence) – (numbers.Real, numbers.Real) |
pair which represents start and end of ellipse. Default (0, 360) |
Example #1:
Python3
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_color = Color( 'black' )
draw.stroke_width = 1
draw.fill_color = Color( 'white' )
origin = ( 100 , 100 )
perimeter = ( 50 , 100 )
draw.ellipse(origin, perimeter)
with Image(width = 200 ,
height = 200 ,
background = Color( 'green' )) as img:
draw.draw(img)
img.save(filename = 'ellipse.png' )
|
Output :
Example #2: Drawing partial ellipse using rotation argument
Python3
from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
with Drawing() as draw:
draw.stroke_color = Color( 'black' )
draw.stroke_width = 1
draw.fill_color = Color( 'white' )
origin = ( 100 , 100 )
perimeter = ( 100 , 50 )
rotation = ( 0 , 270 )
draw.ellipse(origin, perimeter, rotation)
with Image(width = 200 ,
height = 200 ,
background = Color( 'green' )) as img:
draw.draw(img)
img.save(filename = 'ellipsepartial.png' )
|
Output :
Share your thoughts in the comments
Please Login to comment...