|
Author |
Topic: Perfect lines (Read 448 times) |
|
firdosh
|
Perfect lines
« on: Jun 7th, 2004, 4:26pm » |
|
i am drawing an animated line between 2 circles but i cant get a perfect line since i cant pass in doubles as param to the line( ). Any one know a work around this ??
|
|
|
|
justo
|
Re: Perfect lines
« Reply #1 on: Jun 7th, 2004, 5:36pm » |
|
um, i'm not exactly sure what you mean by a "perfect line," but a float has *far* more resolution than even the best anti-aliased renderer could ever provide. if you just want smoother lines try sticking smooth() in your setup() method.
|
|
|
|
kevinP
|
Re: Perfect lines
« Reply #2 on: Jun 7th, 2004, 7:05pm » |
|
on Jun 7th, 2004, 5:36pm, justo wrote:if you just want smoother lines try sticking smooth() in your setup() method. |
| Unless you are using non-filled shapes in which case the smoothed ellipses look worse (006. Here's my quick try (the strokeWeight also still has some bugs): Code: void setup() { size(400, 400); ellipseMode(CENTER_DIAMETER); noFill(); smooth(); } void loop() { background(70, 70, 40); translate(width/2, height/2); // center of each circle float xCenterA = mouseX - (width/2); float yCenterA = mouseY - (height/2); float xCenterB = 2 * xCenterA; float yCenterB = 2 * yCenterA; float angle = atan2( yCenterB - yCenterA, xCenterB - xCenterA ); // angle int rad = 15; // radius of circles // endpoints of connecting line float xPointA = xCenterA + rad * cos(angle); float yPointA = yCenterA + rad * sin(angle); float xPointB = xCenterB - rad * cos(angle); float yPointB = yCenterB - rad * sin(angle); push(); translate(xCenterA, yCenterA); // draw A circle stroke(25, 200, 100); ellipse(0,0, rad * 2, rad * 2); pop(); push(); translate(xCenterB, yCenterB); // draw B circle stroke(220, 100, 25); ellipse(0,0, rad * 2, rad * 2); pop(); strokeWeight(2); // draw connecting line stroke(25, 30, 25); line(xPointA, yPointA, xPointB, yPointB); noStroke(); } |
|
|
Kevin Pfeiffer
|
|
|
|