How to draw a Spiral using arcs in Processing with Python Mode?
Last Updated :
19 Dec, 2021
Processing is a programming language, and a development environment. It is an open-source software to create visual arts, graphics and animation using programming. It supports around 8 different modes, and in this article, we will be using Python Mode.
In this article, we are going to draw a spiral made of arcs using Processing with Python Mode. In case if you have not installed the Processing Software yet, follow this How to setup Python mode for Processing to download and install Processing and setup Python Mode. Here is a preview of what we are going to do. We are going to draw this spiral.
Approach:
- Firstly open Processing software and choose Python Mode.
- Then in the coding part, we are going to define two functions, setup() and draw().
- setup() function is called before the start of the program. Here we have to set the background color and size of the window.
- In the draw() function, we are first setting the fill color of arcs to None using noFill() function. Then stroke color of arcs to white color.
- After that, we are using a loop to create arcs using arc() function. In each iteration we have to increase the height and width of the arc by 50px and tilt the arc by 180 degrees, to form a spiral.
Below is the full implementation:
Here is the Python code for the above approach. Now type the following code in the code editor.
Python3
def setup():
background( 0 )
size( 1000 , 1000 )
def draw():
noFill()
stroke( 255 , 255 , 255 )
for i in range ( 16 ):
if i % 2 = = 0 :
arc( 500 , 525 , 50 + i * 50 , 50 + i * 50 ,
HALF_PI, HALF_PI + PI)
else :
arc( 500 , 500 , 50 + i * 50 , 50 + i * 50 ,
HALF_PI + PI, HALF_PI + 2 * PI)
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...