Skip to content

Commit f3c6646

Browse files
committed
Implement strokeCap/strokeJoin: ROUND enables GL_LINE_SMOOTH, store cap/join state
1 parent 4ce8db2 commit f3c6646

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/Processing.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,15 @@ void PApplet::stroke(float r,float g,float b) {setStrokeFromColor(makeC
852852
void PApplet::stroke(color c) {setStrokeFromColor(c);}
853853
void PApplet::noStroke() {doStroke=false;}
854854
void PApplet::strokeWeight(float w) {strokeW=w;}
855-
void PApplet::strokeCap(int) {}
856-
void PApplet::strokeJoin(int) {}
855+
void PApplet::strokeCap(int mode) {
856+
// ROUND cap: enable line smoothing; SQUARE/PROJECT: disable
857+
currentStrokeCap = mode;
858+
if(mode==ROUND) { glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); }
859+
else { glDisable(GL_LINE_SMOOTH); }
860+
}
861+
void PApplet::strokeJoin(int mode) {
862+
currentStrokeJoin = mode; // stored, used in custom line rendering
863+
}
857864

858865
// =============================================================================
859866
// PCOLOR CONVENIENCE OVERLOADS

src/Processing.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,8 @@ struct PApplet {
40764076
int currentRectMode = CORNER;
40774077
int currentEllipseMode = CENTER;
40784078
int currentImageMode = CORNER;
4079+
int currentStrokeCap = ROUND;
4080+
int currentStrokeJoin = MITER;
40794081

40804082
float tintR = 1, tintG = 1, tintB = 1, tintA = 1;
40814083
bool doTint = false;

0 commit comments

Comments
 (0)