Skip to content
Related Articles

Related Articles

Wand arc() function in Python

View Discussion
Improve Article
Save Article
  • Last Updated : 16 Oct, 2021
View Discussion
Improve Article
Save Article

arc() is a function present in wand.drawing module. arc() function draws an arc in the image. You’ll need to define three pairs of (x, y) coordinates. First & second pair of coordinates will be the minimum bounding rectangle, and the last pair define the starting & ending degree.
 

Syntax : 
 

wand.drawing.arc(start, end, degree)

Parameters : 

 

ParameterInput TypeDescription
startsequence or (numbers.Real, numbers.Real)pair which represents starting x and y of the arc.
endsequence or (numbers.Real, numbers.Real)pair which represents ending x and y of the arc.
degreesequence or (numbers.Real, numbers.Real)pair which represents starting degree, and ending degree 
 

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')
    draw.arc(( 50, 50),  # Stating point
             ( 150, 150),  # Ending point
             (135, -45))  # From bottom left around to top right
    with Image(width = 100,
               height = 100,
               background = Color('green')) as img:
        # draw shape on image using draw() function
        draw.draw(img)
        img.save(filename ='arc.png')

Output: 
 

Example #2:
Source Image: 
 

 

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')
    draw.arc(( 50, 50),  # Starting point
             ( 150, 150),  # Ending point
             (135, -45))  # From bottom left around to top right
    with Image(filename ="gog.png") as img:
        # draw shape on image using draw() function
        draw.draw(img)
        img.save(filename ='arc.png')

Output: 
 

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!