# [Beginner] Create generative art with Processing

#### In this photo:

There are no tags for this photo

on May 10, 2014.

1 of 1 pages

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

or cancel

• 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

## Other photo albums

• #### Food&Code#3: Exhibition party!

5 photos

Activity on Apr 18, 2016

• #### Create Virtual Reality for the web

7 photos

Activity on Nov 9, 2015

• #### Spread & Shine: Digital Art creation at/for Le Pantin.

no photos

Activity on Oct 20, 2015

• #### Create Virtual Reality for the web

1 photo

Activity on Oct 8, 2015

### Move photo

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

Yes, I'm Sure

Yes, I'm Sure

### Brussels, Belgium

Founded Jul 22, 2013

#### People in this Meetup are also in:

• ##### DataScience Meetup

2,174 Business & Data Science pro's

• ##### AngularJS Belgium

1,266 AngularJS Belgium members

• ##### Brussels lean coffee

437 Peers, Practitioners, Learners

• ##### BruJUG - The Brussels Java User Group

525 BruJUGers

• ##### Brussels Bar Trek

2,601 Bar Trekkers