klrohe
YaBB Newbies
Offline
Posts: 1
|
Java exceptions in text area with 2D drawin
Jan 16th, 2008, 10:01pm
When executing the following code:
// // Drawing a conic section using the polar equation // void setup() { size(1200, 800); background(255); noLoop(); }
void draw() { line(width / 2, 0, width / 2, height); line(0, height / 2, width, height / 2); translate(width / 2, height / 2); float p = 150; float e = 1.0; for (int i = 0; i < 10; i++) { conicSection(p, e, 5000); //directrix(p, e); e = e - 0.1; } } void conicSection(float p, float e, int numberOfPoints) { float theta = 0; stroke(100); smooth(); line(-width / 2, p, width / 2, p); line(-width / 2, -p, width / 2, -p);
stroke(0);
strokeWeight(2); for (int i = 0; i < numberOfPoints; i++) { float r = p / (1 - e * cos(theta)); float x = r * cos(theta); float y = r * sin(theta); point(x, y); theta = theta + TWO_PI / numberOfPoints; } // end for } // end conicSection
void directrix(float p, float e) { line(-p / e, -height / 2, -p / e, width / 2); }
I get the following stack trace in the text area:
sun.dc.pr.PRException: endPath: bad path
at sun.dc.pr.Rasterizer.endPath(Unknown Source)
at sun.java2d.pipe.DuctusRenderer.createShapeRasterizer(Unknown Source)
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(Unknown Source)
at sun.java2d.pipe.DuctusShapeRenderer.draw(Unknown Source)
at sun.java2d.SunGraphics2D.draw(Unknown Source)
at processing.core.PGraphicsJava2D.stroke_shape(PGraphicsJava2D.java:484)
at processing.core.PGraphicsJava2D.line(PGraphicsJava2D.java:518)
at processing.core.PGraphicsJava2D.point(PGraphicsJava2D.java:510)
at processing.core.PApplet.point(PApplet.java:7404)
at Temporary_6791_8151.conicSection(Temporary_6791_8151.java:44)
at Temporary_6791_8151.draw(Temporary_6791_8151.java:22)
at processing.core.PApplet.handleDisplay(PApplet.java:1465)
at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
at processing.core.PApplet.run(PApplet.java:1562)
at java.lang.Thread.run(Unknown Source)
|