mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Updated poly examples to use beginContour/endContour, fixed stroke weight calculation in 2D
This commit is contained in:
@@ -3,16 +3,19 @@ size(100, 100, P3D);
|
||||
beginShape(POLYGON);
|
||||
fill(0, 255, 0, 255);
|
||||
stroke(0, 0, 255, 255);
|
||||
strokeWeight(10);
|
||||
strokeWeight(5);
|
||||
strokeJoin(ROUND);
|
||||
beginContour();
|
||||
vertex(10, 10);
|
||||
vertex(10, 90);
|
||||
vertex(90, 90);
|
||||
vertex(90, 10);
|
||||
breakShape();
|
||||
endContour();
|
||||
beginContour();
|
||||
vertex(40, 40);
|
||||
vertex(70, 40);
|
||||
vertex(70, 70);
|
||||
vertex(40, 70);
|
||||
endContour();
|
||||
endShape(CLOSE);
|
||||
|
||||
|
||||
@@ -3,17 +3,20 @@ size(100, 100, P3D);
|
||||
PShape3D obj = (PShape3D)createShape(POLYGON);
|
||||
obj.fill(0, 255, 0, 255);
|
||||
obj.stroke(0, 0, 255, 255);
|
||||
obj.strokeWeight(10);
|
||||
obj.strokeWeight(5);
|
||||
obj.strokeJoin(ROUND);
|
||||
obj.beginContour();
|
||||
obj.vertex(10, 10);
|
||||
obj.vertex(10, 90);
|
||||
obj.vertex(90, 90);
|
||||
obj.vertex(90, 10);
|
||||
obj.breakShape();
|
||||
obj.endContour();
|
||||
obj.beginContour();
|
||||
obj.vertex(40, 40);
|
||||
obj.vertex(70, 40);
|
||||
obj.vertex(70, 70);
|
||||
obj.vertex(40, 70);
|
||||
obj.endContour();
|
||||
obj.end(CLOSE);
|
||||
|
||||
shape(obj);
|
||||
|
||||
@@ -8529,8 +8529,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
float dy = y1 - y0;
|
||||
float len = PApplet.sqrt(dx * dx + dy * dy);
|
||||
|
||||
float linePerpX = -dy * (strokeWeight / len);
|
||||
float linePerpY = dx * (strokeWeight / len);
|
||||
float linePerpX = -dy * (0.5f * strokeWeight / len);
|
||||
float linePerpY = dx * (0.5f * strokeWeight / len);
|
||||
|
||||
tessGeo.putLineVertexIntoFill(inGeo, i0, +linePerpX, +linePerpY, vcount);
|
||||
tessGeo.fillIndices[icount++] = vcount;
|
||||
|
||||
Reference in New Issue
Block a user