As far as I know, scale
within pushMatrix
and popMatrix
can inflate the stroke weight, exaggerating errors. I would try PVector
methods to transform a shape instead. Single precision (32 bit) floating point error might be a contributing factor as well, but there’s little to be done about it with Processing’s methods.
void setup() {
size(400, 400, JAVA2D);
// size(400, 400, P2D);
strokeJoin(MITER);
// strokeJoin(BEVEL);
// strokeJoin(ROUND);
}
void draw() {
PVector coRight = new PVector(1.0, 0.0);
PVector fhRight = new PVector(0.690599, 0.178633);
PVector rhRight = new PVector(0.690599, -0.178633);
PVector coLeft = new PVector(0.0, 0.0);
PVector fhLeft = new PVector(0.309401, -0.178633);
PVector rhLeft = new PVector(0.309401, 0.178633);
// Rotate
float theta = frameCount * TAU / 360.0;
coRight.rotate(theta);
fhRight.rotate(theta);
rhRight.rotate(theta);
coLeft.rotate(theta);
fhLeft.rotate(theta);
rhLeft.rotate(theta);
// Scale
float scale = min(width, height) * 0.5;
coRight.mult(scale);
fhRight.mult(scale);
rhRight.mult(scale);
coLeft.mult(scale);
fhLeft.mult(scale);
rhLeft.mult(scale);
// Translate
PVector origin = new PVector(width / 2.0, height / 2.0);
coRight.add(origin);
fhRight.add(origin);
rhRight.add(origin);
coLeft.add(origin);
fhLeft.add(origin);
rhLeft.add(origin);
background(#fff7d5);
stroke(#202020);
strokeWeight(5.0);
fill(#0080ff);
beginShape();
vertex(coRight.x, coRight.y);
bezierVertex(
fhRight.x, fhRight.y,
rhLeft.x, rhLeft.y,
coLeft.x, coLeft.y);
bezierVertex(
fhLeft.x, fhLeft.y,
rhRight.x, rhRight.y,
coRight.x, coRight.y);
endShape(CLOSE);
}
I got flickering with the P2D
renderer on version 4.4.1 .
Other than that, the default AWT renderer passes the strokeJoin
constant on to BasicStroke
. For an angle that sharp, BEVEL
is what’s left when MITER
raises problems.
If you had access to the AWT renderer directly, you might be able to fiddle with the miterLimit
of the BasicStroke
:
Never tried that myself.