Skip to content

Rotation artifacts when doing 90-degree rotations (are worse than Processing 3) #434

Closed
@processing-bot

Description

@processing-bot

Created by: jbum

Description

I have a script that draws several parts using 90/180/and 270-degree rotations for parts that contain several horizontal and vertical lines. I noticed the lines were often off-true, so I wrote a script to demonstrate the issue. When run in Processing 3, there are a few artifacts, but in Processing 4, the artifacts are significantly worse, as seen in the following screenshots. Interestingly a rectangle with the same dimensions rotates cleanly, but lines and vertex shapes exhibit these artifacts.

Test script is attached. Note: I can see the artifacts are different when using P2D and P3D.

Steps to Reproduce

  1. Run the testing script (below).
  2. Observe the result.

Your Environment

M1 Macbook Air, MacOS 12.2.1
Processing 4.0b6

Result in Processing 4.0b6
CleanShot 2022-03-03 at 21 56 17@2x

Result in Processing 3.5.4
CleanShot 2022-03-03 at 21 56 35@2x

Testing script.

// Rotation test

void setup() {
  size(800,800);
}


void draw() {
  background(255);
  for (int gy = 0; gy < 5; ++gy) {
    float boxSize = map(gy,0,5-1,100,150);
    for (int gx = 0; gx < 5; ++gx) {
      noFill();
      stroke(0);
      float ox = 20 + gx*150;
      float oy = 20 + gy*150;
      pushMatrix();
        translate(ox,oy);
        rect(0,0, boxSize, boxSize);
        translate(boxSize/2, boxSize/2);
        float ang = gx * PI/2.0;
        rotate(ang);
        float irad = boxSize/2;
        
        // this rotates cleanly
        rect(-irad,-10,irad*2,20);
        
        // this has rotation artifacts
        //line(-irad,-10,irad,-10);
        //line(irad,-10,irad,10);
        //line(irad,10,-irad,10);
        //line(-irad,10,-irad,-10);

        // this has the same rotation artifacts as the lines
        beginShape();
        vertex(-irad, -10);
        vertex(irad, -10);
        vertex(irad, 10);
        vertex(-irad, 10);
        endShape(CLOSE);      
      popMatrix();
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions