Yesterday, I got a message from a lovely fellow code lover asking about generative art [I wish I could have helped here more…] it brought with here all the memories of when I wanted to learn generative art because well, have you seen it? It’s awesome! Especially for people who love art yet their arms aren’t magic, and they could barely draw a stick figure, but they’re kinda decent in math [yours truly here]. I’ve been meaning to learn it, but kept putting it off, because of geometry… But yesterday, I was like ‘You know what! you wanted to start learning new things, so your project tomorrow will be generative art related whether you like it or not!”. Man what a long intro… But you get the picture, generative art it is.
First off, I well wanted to test out the waters. I wanted to draw random lines each couple of seconds and at random positions. and well
it sorta reminded me of my thought process. How it starts random, and then all of a sudden takes a dark turn. All in all, we got the basics out and figured out the structure. So off to the project. The project idea isn’t original. I bet you saw a lot of bubble generating code out there, but I never did it so it’s time to learn to do it. At the start, I wanted to draw out the bubble
okay, awesome! we have our bubble. it’s time to move it so let’s try it out!
eesh, what the… Well, it turns out I have to clear the screen before drawing another bubble so after adding that tweak
yay! we have a moving bubble! However, what a weird movement position because let’s face it, we never saw a bubble move horizontally but rather vertically. So let’s play a bit with the coordinates
okay, we’re getting there. but bubbles define gravity [ how many of you started singing the song?] so
hmm. It’s right but let’s have it rise from the bottom of the screen to the top.
okay time for generating more and more bubbles and
it seems they need to have a bit of randomization to them so let’s add that
Awesome! Now, time for some user interaction. After they click on the bubble it pops. And the process was, 1. get the mouse coordinate
2. make sure it calls the popped function. (for testing we ass a log message)
Brilliant! 3. finally make it actually pop by making it disappear, and add a text that says pop.
https://athougcodesatnight.com/wp-content/uploads/14.jpg345480athoughttps://athougcodesatnight.com/wp-content/uploads/Athoug-Codes-at-night_text-300x138.pngathoug2017-12-23 02:30:002017-12-30 10:11:00Bubbles, Here There and Everywhere Day 18