Learn creative coding writing simple programs

120. Interactive file visualizer using loadBytes

Here we modify the program that used loadBytes to display the content of a file as colored vertical lines.

The original program just displayed the first six hundred bytes as an static image. Now we add interactivity, so by moving the mouse left and right we can explore the content of the complete file.

The required changes are very few. We add setup() and draw() functions to animate the thing, and then we just add a new variable that contains a number. The number is used to avoid always reading from the beginning of the file. This number is an offset. To calculate the number we use map(). We map the horizontal position of the mouse in the screen to the position inside the loaded file.

Note: I tried loading different files and found that files with .ico extension produce very interesting patterns :)

Tags: loadBytes, visualize, bytes

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