processing.py : trails using oop

trails in processing.py
trails in processing.py

in this post, we’ll explain how to add trails using an oop approach.

a trail is basically objects that appear where the primary objects passed

in nature, trails are made by particles of the primary object but in programming, one simple approach is to draw other shapes albeit more small

the full code

there is the full processing.py code :

explanations

in the constructor,

is basically a simple list

we added to the list on each call of the update method. then if there are more than 200 elements in the list, we remove one element

for the shapes, we just draw vertices (hey lines) joining all the points in the list

finally the run method is included for convenience so that we need to only call one method !

in setup, we just define a new object

then in draw we call the run method

conclusion

adding oop allows for much more flexibility than hardcoding it all !

here it is in action :

Lives in Mauritius, cruising python waters for now.