N/APosted on - 05/29/2015
I am new to Python and have started with basic Integrated development environment. I will take three inputs from the user and they will the radius of the circles, number of circles and the color. Finally my job is to choose a suitable background based on the circle color and draw those circle with the radius mentioned and create a image. I am very new to this and if somebody can guide me towards image creating in python, i will be greatly thankful. Also, let me know if other python wrappers are available for the same purpose.
How to generate circles in images in python
In drawing circles, or other shapes be it regular or irregular with the use of Pillow’s ImageDraw Module the following are some of the methods. Note that the fill and outlined guidelines for these methods are not obligatory and will default to a white colour if left undefined.
With the use of the Point (xy, fill) method in drawing shapes, the xy argument denotes an itemized coordinates needed to draw a shape. These lists could be a list of x- and y-coordinate tuples. An example is [(x, y), (x, y), …], or it could also be a list of x- and y-coordinates exclusive of tuples, an example being [x1, y1, x2, y2, …]. The fill argument is as well optional in that the colour of the points as well as being either an RGBA tuple or string of colour name for instance ‘blue’.
In drawing a circle with the use of the Ellipse (xy, fill, outline) method the xy argument is a box tuple (left, top, right, bottom) denoting a box specifically containing the ellipse. For the width and height of the ellipse being identical, this very method will draw a circle. The discretionary fill argument is the colour of the inner side of the ellipse as the optional outline argument is the ellipse outline colour.
This is an example: draw.ellipse((20, 20, 180, 180), fill = 'blue', outline ='blue')