Distorted Rect()
in
Programming Questions
•
2 years ago
I had strange arrow shaped where I was expecting rectangles. (why this always happening to me?...)
I managed to track down the precise cause.
Tiny rectangles (just a few pixels) are distorted, which is fine (and can't be helped) since we can barely see them.
But a large strokeWeight() magnify their outline, making visible their distorted nature.
It's kind of a bug, but an inevitable one I guess.
Try this:
- void setup() {
size(765,450);
noLoop();
//
for (int xx=25; xx<751; xx+=50) {
showRec(xx,15, 15,15, (xx/40)*PI/10.0, 1);
}
for (int xx=25; xx<751; xx+=50) {
showRec(xx,50, 15,15, (xx/40)*PI/10.0, 25); //strokeWeight=25, size=15,15
}
//
for (int xx=25; xx<751; xx+=50) {
showRec(xx,90, 5,5, (xx/40)*PI/10.0, 1);
}
for (int xx=25; xx<751; xx+=50) {
showRec(xx,120, 5,5, (xx/40)*PI/10.0, 25); //strokeWeight=25, size=5,5
}
//
for (int xx=25; xx<751; xx+=50) {
showRec(xx,160, 2,2, (xx/40)*PI/10.0, 1);
}
for (int xx=25; xx<751; xx+=50) {
showRec(xx,190, 2,2, (xx/40)*PI/10.0, 25); //strokeWeight=25, size=2,2
}
//
for (int xx=25; xx<751; xx+=50) {
showRec(xx,230, 1,1, (xx/40)*PI/10.0, 1);
}
for (int xx=25; xx<751; xx+=50) {
showRec(xx,260, 1,1, (xx/40)*PI/10.0, 25); //strokeWeight=25, size=1,1
}
//
for (int xx=25; xx<751; xx+=50) {
showRec(xx,300, 1,0, (xx/40)*PI/10.0, 1);
}
for (int xx=25; xx<751; xx+=50) {
showRec(xx,370, 1,0, (xx/40)*PI/10.0, 25); //strokeWeight=25, size=1,0
}
//
} - void draw() {
} - void showRec(int x, int y, int sizx, int sizy, float rot, int weight) {
stroke(color(25,125,225,150));
fill(color(225,125,25,255));
strokeWeight(weight);
rectMode(CENTER);
pushMatrix();
translate(x,y);
rotate(rot);
rect(0,0,sizx,sizy);
popMatrix();
rectMode(CORNER);
}
1