all i'm saying there are reasons why the inner part of a rect looks differently than a line. for instance, really how thick is this rect with it's corners one 1px apart but without rendering it's borders? as i stated above, as soon as you use borders on the rect it starts to look like the line.
so, i don't agree that a line should look the same as a 1px wide rect with noStroke(). a line should look the same as a 1px wide rect *with* stroke(), and it does.
so this inner part of the rect is a different matter, and maybe that's exactly why rect() is slower.
I agree that the antialiasing achieved with the rect looks really nice. Maybe there is a way to replicate it with a lines, using strokeWeight and opacity?
here are some tests:
- void setup() {
- size(400, 500);
- smooth();
- rectMode(CENTER);
- background(0);
- stroke(255);
- fill(255);
- }
- void draw() {
- // rect, no stroke, 1px apart
- pushMatrix();
- noStroke();
- translate(frameCount, 50);
- rotate(frameCount / 100.0);
- rect(0, 0, 1, 80);
- popMatrix();
-
- // line
- pushMatrix();
- stroke(255);
- strokeWeight(1);
- translate(frameCount, 150);
- rotate(frameCount / 100.0);
- line(0, -40, 0, 40);
- popMatrix();
-
- // rect, with stroke, 1px apart
- pushMatrix();
- stroke(255);
- strokeWeight(1);
- translate(frameCount, 250);
- rotate(frameCount / 100.0);
- rect(0, 0, 1, 80);
- popMatrix();
-
- // rect, with stroke, 0px apart
- pushMatrix();
- stroke(255);
- strokeWeight(1);
- translate(frameCount, 350);
- rotate(frameCount / 100.0);
- rect(0, 0, 0, 80);
- popMatrix();
-
- // line, using strokeWeight, and opacity
- pushMatrix();
- stroke(255, 200);
- strokeWeight(1.5);
- translate(frameCount, 450);
- rotate(frameCount / 100.0);
- line(0, -40, 0, 40);
- popMatrix();
-
-
- if(frameCount > width) {
- noLoop();
- }
- }