IllegalArgumentException: negative width
processing.app.debug.RunnerException: IllegalArgumentException: negative width
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:583)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.IllegalArgumentException: negative width
at java.awt.BasicStroke.<init>(BasicStroke.java:181)
at java.awt.BasicStroke.<init>(BasicStroke.java:254)
at processing.core.PGraphicsJava2D.strokeImpl(PGraphicsJava2D.java:1427)
at processing.core.PGraphicsJava2D.strokeWeight(PGraphicsJava2D.java:1408)
at processing.core.PGraphics3D.rawPoints(PGraphics3D.java:1072)
at processing.core.PGraphics3D.endShape(PGraphics3D.java:660)
at processing.core.PGraphics.endShape(PGraphics.java:1181)
at processing.core.PGraphics.point(PGraphics.java:1448)
at processing.core.PApplet.point(PApplet.java:7789)
at Volkswagen_Grafik_3.draw(Volkswagen_Grafik_3.java:132)
at processing.core.PApplet.handleDraw(PApplet.java:1606)
at processing.core.PApplet.run(PApplet.java:1503)
at java.lang.Thread.run(Thread.java:637)
The code
// Thanks to Generative Gestaltung for the code of the mesh drawing!// Thanks to Amnon Owed for helping me out
import processing.opengl.*;import processing.pdf.*;import controlP5.*;
ControlP5 myP5;ControlWindow myGUIWindow;
// horizontalint uCount = 28;float uMin = 4.13;float uMax = 5.20;
// verticalint vCount = 28;float vMin = 0.40;float vMax = -0.39;
// panningfloat xwidth = 0.47;float yheight = 0.5;
// extrafloat magnification = 250;
// view rotationint offsetX = 0, offsetY = 0, clickX = 0, clickY = 0;float rotationX = -14.10, rotationY = -3.77, targetRotationX = 0, targetRotationY = 0, clickRotationX, clickRotationY;
boolean savePDF = false;PImage boven;PImage onder;PImage links;PImage rechts;
void setup() {size(600, 600, OPENGL);hint(ENABLE_OPENGL_4X_SMOOTH);boven = loadImage("boven.png");onder = loadImage("onder.png");links = loadImage("links.png");rechts = loadImage("rechts.png");// controlp5 setupmyP5 = new ControlP5(this);myP5.setAutoDraw(false);myGUIWindow = myP5.addControlWindow("GUI_WINDOW", 600,105);myGUIWindow.hideCoordinates();// control window setupmyGUIWindow.setTitle("Werte wählen");Controller mySlideruMin = myP5.addSlider("uMin",-5,5, uMin, 10, 10, 225, 10);mySlideruMin.setWindow(myGUIWindow);Controller mySlideruMax = myP5.addSlider("uMax",-5,5, uMax, 10, 25, 225, 10);mySlideruMax.setWindow(myGUIWindow);Controller mySlidervMin = myP5.addSlider("vMin",-5,5, vMin, 10, 40, 225, 10);mySlidervMin.setWindow(myGUIWindow);Controller mySlidervMax = myP5.addSlider("vMax",-5,5, vMax, 10, 55, 225, 10);mySlidervMax.setWindow(myGUIWindow);Controller mySlidervCount = myP5.addSlider("vCount",1,100, vCount, 10, 70, 225, 10);mySlidervCount.setWindow(myGUIWindow);Controller mySlideruCount = myP5.addSlider("uCount",1,100, uCount, 10, 85, 225, 10);mySlideruCount.setWindow(myGUIWindow);Controller mySliderrotationX = myP5.addSlider("rotationX",-50,50, rotationX, 305, 10, 225, 10);mySliderrotationX.setWindow(myGUIWindow);Controller mySliderrotationY = myP5.addSlider("rotationY",-50,50, rotationY, 305, 25, 225, 10);mySliderrotationY.setWindow(myGUIWindow);Controller mySliderxwidth = myP5.addSlider("xwidth",-2.5,2.5, xwidth, 305, 40, 225, 10);mySliderxwidth.setWindow(myGUIWindow);Controller mySlideryheight = myP5.addSlider("yheight",-2.5,2.5, yheight, 305, 55, 225, 10);mySlideryheight.setWindow(myGUIWindow);Controller mySlidermagnification = myP5.addSlider("magnification",1,400, magnification, 305, 70, 225, 10);mySlidermagnification.setWindow(myGUIWindow);}
void draw() {String filename = int(uMin*10)+"_"+int(uMax*10)+"_"+int(vMin*10)+"_"+int(vMax*10)+"_";if (savePDF) beginRaw(PDF, filename+timestamp()+".pdf");
background(0);image (boven,0,0);image (onder,0,547);image (links,0,56);image (rechts,548,56);noFill();stroke(255);
setView();scale(magnification);
// draw meshfor (float iv = vCount-1; iv >= 0; iv--) {beginShape();for (float iu = 0; iu <= uCount; iu++) {float u = map(iu, 0, uCount, uMin, uMax);float v = map(iv, 0, vCount, vMin, vMax);
float x = 0.75*v;float y = sin(u)*v;float z = cos(u)*cos(v);vertex(x, y, z);
v = map(iv+1, 0, vCount, vMin, vMax);x = 0.75*v;y = sin(u)*v;z = cos(u)*cos(v);vertex(x, y, z);strokeWeight(0.2 + z*0.5 + u*0.5 + v*0.5);point(x,y,z);}endShape();}// image outputif(savePDF == true) {endRaw();savePDF = false;}}
void keyPressed(){if(key=='p' || key=='P') savePDF = true;println("U Range: " + nf(uMin,0,1) + " - " + nf(uMax,0,1) + " | V Range: " + nf(vMin,0,1) + " - " + nf(vMax,0,1));}
void setView() {translate(width*xwidth,height*yheight);rotateX(-rotationY);rotateY(rotationX);}
String timestamp() {return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", Calendar.getInstance());}