Friday, December 27, 2024
Google search engine
HomeLanguagesWand ellipse() function in Python

Wand ellipse() function in Python

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




# 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
 
    # fill white color in arc
    draw.fill_color = Color('white')
    origin = (100, 100)
    perimeter = (50, 100)
 
    # draw circle using ellipse() function
    draw.ellipse(origin, perimeter)
    with Image(width = 200,
               height = 200,
               background = Color('green')) as img:
        # draw shape on image using draw() function
        draw.draw(img)
        img.save(filename ='ellipse.png')


Output : 
 

Example #2: Drawing partial ellipse using rotation argument 
 

Python3




# 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
 
    # fill white color in arc
    draw.fill_color = Color('white')
    origin = (100, 100)
    perimeter = (100, 50)
    rotation = (0, 270)
 
    # draw circle using ellipse() function
    draw.ellipse(origin, perimeter, rotation)
    with Image(width = 200,
               height = 200,
               background = Color('green')) as img:
        # draw shape on image using draw() function
        draw.draw(img)
        img.save(filename ='ellipsepartial.png')


Output : 
 

 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments