From 24126bc840c2777266c61230d86418a60539eda8 Mon Sep 17 00:00:00 2001 From: lapin Date: Wed, 7 Oct 2020 00:33:11 +0200 Subject: [PATCH] tunelle droit avec des cercle qui avence --- LaserOut.pde | 3 +- test_laserisation.pde => laser_tunnel.pde | 80 +++++++++++++++++------ remove_me | 0 3 files changed, 61 insertions(+), 22 deletions(-) rename test_laserisation.pde => laser_tunnel.pde (62%) delete mode 100644 remove_me diff --git a/LaserOut.pde b/LaserOut.pde index cc757a8..d2ce159 100644 --- a/LaserOut.pde +++ b/LaserOut.pde @@ -30,8 +30,7 @@ public class LaserOut { // to terminate json array laser_out += "]"; - println(laser_out); -// println("\n\n==\n\n"); + println(laser_out); // flush the string, prepar for next frame laser_out = ""; diff --git a/test_laserisation.pde b/laser_tunnel.pde similarity index 62% rename from test_laserisation.pde rename to laser_tunnel.pde index 8b11c5a..33f522f 100644 --- a/test_laserisation.pde +++ b/laser_tunnel.pde @@ -39,28 +39,11 @@ Point[] create_circle(float center_x, float center_y, float radius, int nb_point void setup() { size(800, 800); - background(255); + background(0); // ... // circle = create_circle(400, 400, 70, 25); laser_frame = new LaserOut(); - - -//////////// - - int rad, radm, nb_point; - float cx, cy; - - nb_point = 25; - rad = 40; - radm = rad / 2; - cx = 400; - cy = 400; - c1 = create_circle( cx, cy, rad, nb_point, getColInt(255, 255, 255)); - c2 = create_circle(cx - radm, cy - radm, rad, nb_point, getColInt( 0, 255, 0)); - c3 = create_circle(cx + radm, cy - radm, rad, nb_point, getColInt( 0, 0, 255)); - c4 = create_circle( cx, cy + radm, rad, nb_point, getColInt(255, 0, 0)); - } int getColInt(int r, int g, int b) @@ -71,7 +54,20 @@ int getColInt(int r, int g, int b) return (col); } -void draw(){ +void draw_circle_test(){ + int rad, radm, nb_point; + float cx, cy; + + nb_point = 25; + rad = 40; + radm = rad / 2; + cx = 400; + cy = 400; + + c1 = create_circle( cx, cy, rad, nb_point, getColInt(255, 255, 255)); + c2 = create_circle(cx - radm, cy - radm, rad, nb_point, getColInt( 0, 255, 0)); + c3 = create_circle(cx + radm, cy - radm, rad, nb_point, getColInt( 0, 0, 255)); + c4 = create_circle( cx, cy + radm, rad, nb_point, getColInt(255, 0, 0)); // ajoute une chaine de charactere a la frame + dessine sur processing laser_frame.add_line(c1); @@ -79,5 +75,49 @@ void draw(){ laser_frame.add_line(c3); laser_frame.add_line(c4); - laser_frame.print_frame(); +} + +float get_distance(int id, int max_id, float distance, float prct_anime) +{ + float dist; + + dist = ((float(id) / float(max_id)) + prct_anime) % 1.0; + return (dist); +} + +void draw_tunel(int time_milis){ + // on va tracer des crecle qui vont se raprocher et des ligne sur ces cercle + // plus les cercle sont loin plus les cercle on un radius petit + + // on va aussi tracer des cercle + + int nb_circle = 20; + int time_periode = 5 * 1000; // 10 seconde + float distance = 20; + float prct_anime = 5 - (float(time_milis % time_periode) / float(time_periode)); + int pt_per_circle = 15; + + // position du cercle + // radius + int cx, cy, radius, r; + + cx = 400; + cy = 400; + radius = 30; + + float prct; + + for (int i = 0; i < nb_circle; i++){ + prct = float(i) / float(nb_circle); + prct = 1; + r = int(float(radius) / get_distance(i, nb_circle, distance, prct_anime)); + + laser_frame.add_line(create_circle(cx, cy, r, pt_per_circle, getColInt(int(255 * prct), int(255 * prct), int(255 * prct)))); + } +} + +void draw(){ + background(0); + draw_tunel(millis()); + laser_frame.print_frame(); } diff --git a/remove_me b/remove_me deleted file mode 100644 index e69de29..0000000