diff --git a/bouncing_ball_with_vector/boucing_ball_with_vector.pde b/bouncing_ball_with_vector/boucing_ball_with_vector.pde new file mode 100644 index 0000000..7ffad2a --- /dev/null +++ b/bouncing_ball_with_vector/boucing_ball_with_vector.pde @@ -0,0 +1,41 @@ +class PVector { + float x, y; + + PVector(float x_, float y_) { + x = x_; + y = y_; + } + + void add(PVector other) { + x += other.x; + y += other.y; + } +} + +PVector location; +PVector velocity; + +void setup() { + size(640, 360); + background(255); + location = new PVector(100, 100); + velocity = new PVector(1, 3.3); +} + +void draw() { + background(255); + + location.add(velocity); + + if ((location.x > width) || (location.x <= 0)) { + velocity.x *= -1; + } + if ((location.y > height) || (location.y <= 0)) { + velocity.y *= -1; + } + + stroke(0); + fill(175); + ellipse(location.x, location.y, 16, 16); + +} \ No newline at end of file diff --git a/test_export_svg/test_export_svg.pde b/test_export_svg/test_export_svg.pde new file mode 100644 index 0000000..3c1a503 --- /dev/null +++ b/test_export_svg/test_export_svg.pde @@ -0,0 +1,22 @@ +import processing.svg.*; + + + +void setup() { + size(400, 400); + noLoop(); + background(220, 220, 220); + beginRecord(SVG, "/home/yaf/filename.svg"); +} + +void draw() { + for(int i = 0; i < 10; i++) { + int rouge = int(random(250)) % 255; + int vert = int(random(230)) % 255; + int bleu = int(random(250)) % 255; + color couleur_du_moment = color(rouge, vert, bleu); + fill(couleur_du_moment); + quad(int(random(width)), int(random(height)), int(random(width)), int(random(height)), int(random(130)), int(random(163)), int(random(180)), int(random(176))); + } + endRecord(); +}