We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there I have a code query. I am wanting to create a illustration out of lines that at one point are cemented and the other moveable (preferably all together). I have made small alterations to an existing code but this is not quite working. I would like the arm to do a full 360 rotation. I would like to be able to multiple lines that all follow the mouse together
Any suggestion or help is greatly appreciated!
float x, y;
float angle1 = 0.0;
float segLength = 100;
void setup() {
size(700, 700);
strokeWeight(10);
stroke(200, 160);
x = width * 0.5;
y = height * 0.5;
}
void draw() {
background(0);
angle1 = (mouseX/float(width) - 0.0) * -PI;
pushMatrix();
segment(x, y, angle1);
popMatrix();
}
void segment(float x, float y, float a) {
translate(x, y);
rotate(a);
line(0, 0, segLength, 0);
}
Answers
for the 360º just replace
PI
byTWO_PI
. Or maybe a more trigonometric approach :)Not sure what you need for several lines, but click the mouse to see some. That's usually call for an OOP approach though... Also to paste code, ident 4 spaces each line, or paste/select/hit 'C' button, it will ident for you ;)