addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonJoin Group on CardStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

May 10, 2014 - 15 went

[Beginner] Create generative art with Processing

In this photo:

There are no tags for this photo

Added by Piet B.
on May 10, 2014.
 

Comments

  • beeeeber

    Like I said during the workshop, very nice work ! Could you share the code ? Thank's a lot !

    or cancel

  • Piet B.

    I figured out a way to get something on youtube: https://www.youtube.com/watch?v=d8-b2hev9D0&feature=youtu.be I'll paste the code underneath. It's mainly the code of the tutorial. Just playing around with number of particles and their origin, adding colour and transparency and not to forget the random function. At the end I also added video library to save each frame in a png file to be able to make a slideshow movie with the command line application mmpeg under ubuntu: ffmpeg -r 1/0.02 -pattern_type glob -i '*.png' -c:v libx264 out.mp4 (it took a while to install ffmpeg, but it seems worthwhile to install) 'saveFrame' in the last line is slowing processing down with a factor of about 20, so you might want to comment the saveFrame function if you don't want like these thousands of frames in separate files. The code: PVector[] p, s, a; //Defines the particles int k; // Define the number of particles color[] colours; void setup() { size(1920,1080); background(255); noCursor(); k = 1000; // We want 20 of them apples // Define the size of the particle array by the number // / of particle we want p = new PVector[k]; s = new PVector[k]; a = new PVector[k]; colours = new color[k]; // Initialise the acceleration, speed and position arrays. for(int i=0; i<k; i++) { // Initial position at the left of the screen, with random y // To initialise a PVector, we use PVector(x,y) // / with values for x and y p[i] = new PVector(960,540); s[i] = new PVector(random(-0.01,0.01),random(-0.01,0.01)); // Initial speed toward the right a[i] = new PVector(0,0); colours[i] = color(0,0,0,random(255)); } } void draw() { //Update acceleration, speed and position for(int i=0; i<k; i++) { a[i] = new PVector(random(0.01)-0.005, random(0.01)-0.005); s[i].add(a[i]); // You can’t add vectors together with + p[i].add(s[i]); // / to do so, you need to call add. } // Draw the particles for(int i=0; i<k; i++) { stroke(colours[i]); point(p[i].x, p[i].y); // Here we use the point primitive } saveFrame("frame-######.png"); }

    or cancel

Want to comment on this photo?

Sign in, if you're already a member of this group or Join OpenTechSchool Brussels

Other photo albums

Move photo

Do you want to move this photo to “__ALBUM_NAME__”?

Are you sure you want to delete this photo?

Yes, I'm Sure

Are you sure you want to delete this comment?

Yes, I'm Sure

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy