Skip to content

Commit a259fce

Browse files
committed
Add rect(x,y,w,h,tl,tr,br,bl) implementation
1 parent 158d3c0 commit a259fce

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/Processing.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
#if __has_include("stb_truetype.h")
1+
#
2+
void PApplet::rect(float x,float y,float w,float h,float tl,float tr,float br,float bl){
3+
if(!doFill && !doStroke) return;
4+
float x2=x+w, y2=y+h;
5+
beginShape();
6+
vertex(x+tl,y); vertex(x2-tr,y);
7+
if(tr>0){for(int i=0;i<=8;i++){float a=PI+HALF_PI+HALF_PI*i/8.f;vertex(x2-tr+::std::cos(a)*tr,y+tr+::std::sin(a)*tr);}}
8+
vertex(x2,y+tr); vertex(x2,y2-br);
9+
if(br>0){for(int i=0;i<=8;i++){float a=HALF_PI*i/8.f;vertex(x2-br+::std::cos(a)*br,y2-br+::std::sin(a)*br);}}
10+
vertex(x2-br,y2); vertex(x+bl,y2);
11+
if(bl>0){for(int i=0;i<=8;i++){float a=HALF_PI+HALF_PI*i/8.f;vertex(x+bl+::std::cos(a)*bl,y2-bl+::std::sin(a)*bl);}}
12+
vertex(x,y2-bl); vertex(x,y+tl);
13+
if(tl>0){for(int i=0;i<=8;i++){float a=PI+HALF_PI*i/8.f;vertex(x+tl+::std::cos(a)*tl,y+tl+::std::sin(a)*tl);}}
14+
endShape(CLOSE);
15+
}
16+
if __has_include("stb_truetype.h")
217
# define PROCESSING_HAS_STB_TRUETYPE 1
318
# define STB_TRUETYPE_IMPLEMENTATION
419
# include "stb_truetype.h"

0 commit comments

Comments
 (0)