2020-10-06 20:55:32 +00:00
|
|
|
|
|
|
|
public void processing_draw_line(Point[] line)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Point p1, p2;
|
|
|
|
|
|
|
|
for (i = 0; i < line.length - 1; i++)
|
|
|
|
{
|
|
|
|
p1 = line[i];
|
|
|
|
p2 = line[i + 1];
|
|
|
|
|
|
|
|
stroke(p1.r, p1.g, p1.b);
|
|
|
|
line(p1.x, p1.y, p2.x, p2.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class LaserOut
|
|
|
|
{
|
|
|
|
String laser_out;
|
|
|
|
boolean is_empty;
|
|
|
|
|
|
|
|
LaserOut()
|
|
|
|
{
|
|
|
|
laser_out = new String();
|
|
|
|
laser_out += "[";
|
|
|
|
is_empty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_frame()
|
|
|
|
{
|
|
|
|
// to terminate json array
|
|
|
|
laser_out += "]";
|
2020-10-06 22:33:11 +00:00
|
|
|
println(laser_out);
|
2020-10-06 20:55:32 +00:00
|
|
|
|
|
|
|
// flush the string, prepar for next frame
|
|
|
|
laser_out = "";
|
|
|
|
//laser_out = new String();
|
|
|
|
laser_out += "[";
|
|
|
|
is_empty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void add_line(Point[] line)
|
|
|
|
{
|
|
|
|
if (is_empty)
|
|
|
|
is_empty = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
laser_out += ", ";
|
|
|
|
}
|
|
|
|
// on met un point noir quoi qu'il arrive
|
|
|
|
laser_out += "[" + str(line[0].x) + ", " + str(line[0].y) + ", 0]";
|
|
|
|
for (int i = 0; i < line.length; i++)
|
|
|
|
{
|
|
|
|
laser_out += ", [" + str(line[i].x) + ", " + str(line[i].y) + ", " + str(line[i].col) + "]";
|
|
|
|
}
|
|
|
|
laser_out += ", [" + str(line[line.length - 1].x) + ", " + str(line[line.length - 1].y) + ", 0]";
|
|
|
|
|
|
|
|
processing_draw_line(line); // On pourait rajouter une condition si un paraetre est activer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|