Python PIL | ImageDraw.Draw.arc()
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageDraw
module provide simple 2D graphics for Image objects. You can use this module to create new images, annotate or retouch existing images, and to generate graphics on the fly for web use.
ImageDraw.Draw.arc()
draws an arc (a portion of a circle outline) between the start and end angles, inside the given bounding box.
Syntax: PIL.ImageDraw.Draw.ellipse(xy, fill=None, outline=None)
Parameters:
xy – Four points to define the bounding box. Sequence of [(x0, y0), (x1, y1)] or [x0, y0, x1, y1].
start – Starting angle, in degrees. Angles are measured from 3 o’clock, increasing clockwise.
end – Ending angle, in degrees.
fill – Color to use for the arc.
Returns: An Image object in arc shape.
import math
from PIL import Image, ImageDraw
w, h = 220 , 190
shape = [( 40 , 40 ), (w - 10 , h - 10 )]
img = Image.new( "RGB" , (w, h))
img1 = ImageDraw.Draw(img)
img1.arc(shape, start = 20 , end = 130 , fill = "pink" )
img.show()
|
Output:
Another Example: Here we use different colour for filling.
import math
from PIL import Image, ImageDraw
w, h = 220 , 190
shape = [( 40 , 40 ), (w - 10 , h - 10 )]
img = Image.new( "RGB" , (w, h))
img1 = ImageDraw.Draw(img)
img1.arc(shape, start = 20 , end = 130 , fill = "red" )
img.show()
|
Output:
Last Updated :
02 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...