![]() |
VOOZH | about |
Creative programming is a type of programming approach in which the goal is to create something expressive and visual instead of something that is purely functional. This type of programming approach is used to create live artworks, graphical simulations and visualize algorithms. There exists a number of tools and libraries for creative or visual programming of which Processing is the most widely used. Processing is an open source programming language and IDE that built for visual programming purposes. Processing is available for free download here. It is also available as a python dialect(processing.py) and a javascript framework(p5.js). In this article we will build a simple random walker program which is just a ball moving randomly across the canvas.
Each processing sketch typically consists of two functions-
Implementation of sketch- The sample codes have been written in java using the processing library and the processing IDE.
Implementation of Walker class-
At this point if we run the sketch, it just displays a ball that sits at the centre of the output screen- In order to move the walker object, we will add a walk() function to the Walker class and call it inside the draw() function in the sketch. We also add a checkEdges() function in Walker to prevent the Walker object from moving out of the screen. We must also modify the sketch to include the new functions we add in the Walker class. We can also do one more thing, move the background() function inside setup(). This way, the background will not be updated every time and we will be able to see the trail, the Walker object leaves behind.
Modified Implementation of sketch-
Modified Implementation of Walker class-