Learn creative coding writing simple programs

51. Convert float into int and animate a photo

We now continue with the program started in episode 49 where we copy() part of a photo and show this part on our screen. The idea is to animate it by moving which part of the loaded photo we show. If we randomly change the vertical position of the part we copy, we will have an interesting effect. But we encounter a little problem: copy accepts only integer values like 2, 5, 33 or 43, but random() and noise() return float values like 1.4325 or 38.4124. We solve this by converting the float value into an integer by using the int() function.

Tags: copy, int, float, convert, datatype, software tutorial

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus