sketch shows grey window
in
Library and Tool Development
•
4 months ago
I continued to work on something i worked on a year ago.
Strange thing is i have a problem now which i didn't have before.
here is the jar that is needed:
https://dl.dropboxusercontent.com/u/17630770/temp/DoekeLibs.jar
Thing is, the screen is grey. But when i dissable ellipse somewhere (see comment in code) everything is ok.
Also when i use noLoop it draws correct.
The hard thing is i don't get any errors.
It happens in 1.5.1 as in 2.0.9.
how can i debug such thing?
- import nl.doekewartena.path.*;
- import nl.doekewartena.deform.*;
- Deformer2D def;
- ArrayList<PVector> points = new ArrayList<PVector>();
- ArrayList<PVector> deformedPoints = new ArrayList<PVector>();
- void setup() {
- size(500, 800);
- smooth();
- String pString =
- "vertex(42.0, 96.0);" +
- "bezierVertex(59.0, 173.0, 277.0, -128.0, 154.0, 143.0);" +
- "bezierVertex(31.0, 414.0, 182.0, 278.0, 191.0, 262.0);" +
- "endShape();";
- // a deformer supports the same ways to be created as a BezierVertexPath
- def = new Deformer2D(this, pString);
- for(int y = 50; y < 80; y+=3) {
- for(int x = 50; x < 450; x+=3) {
- points.add(new PVector(x, y));
- // points have to be init for the deformer
- // so it knows the min and max values for x and y (and z if used)
- def.init(x, y);
- // or
- //def.initX(x);
- //def.initY(y);
- //def.init(x, y, z);
- //def.init(PVector p);
- }
- }
- // before a deform get's used update it
- // this will do some calculations that are needed
- // for the deformer to work
- def.update();
- // if you deform a new set of points then call
- // def.reset();
- // and then call def.update(); again
- }
- void draw() {
- println("draw");
- background(0);
- pushMatrix();
- // draw the path
- stroke(255);
- noFill();
- def.draw();
- // the original points
- fill(255, 0, 0, 100);
- noStroke();
- for(PVector pv : points) {
- ellipse(pv.x, pv.y, 3, 3);
- }
- // the deformed points by passing a ArrayList
- translate(0, 100);
- // no arc length parameterization
- def.alp(false);
- deformedPoints = def.deform(points);
- fill(0, 255, 255);
- noStroke();
- for(PVector pv : deformedPoints) {
- ellipse(pv.x, pv.y, 3, 3);
- }
- translate(200, 50);
- // and use arc length parameterization
- def.alp(true);
- // move your mouse horizontal to see the effect
- // of stepAccuracy, if it is to low points will overlap
- float v = map(mouseX, 0, width, 0.1, 1);
- def.precision(v);
- fill(255, 255, 0);
- noStroke();
- float x, y;
- // deform by passing xy is also possible
- for(PVector pv : points) {
- // library or processing BROKEN!
- x = def.deformX(pv.x, pv.y);
- y = def.deformY(pv.x, pv.y);
- //println(y);
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // either disable this
- ellipse(x, y, 3, 3);
- }
- popMatrix();
- fill(255);
- text("precision: "+v, mouseX, mouseY);
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // or enable this
- // noLoop();
- }
1