# Issue when rendering small rectangles

**URL:** <https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217>\
**Category:** Coding Questions\
**Created:** [August 4, 2022, 3:44am UTC](https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217 "2022-08-04T03:44:07Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 7, 2022, 12:49am UTC](https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217/5 "2022-08-07T00:49:15Z")

</div>

Hello,

A very simple pixel viewer that I use to zoom in on sketch.

Try different renderers, smooth() values, etc.

I even tried odd and even. No pun intended!

Some code for you to experiment with:

```auto
// Pixel Viewer
// v1.0.0
// GLV 2022-08-06

PImage img; 
boolean toggle;
int oddeven, count, choice;

void setup() 
  {
  //size(650, 600);   
  size(650, 600, P2D); 
  //size(650, 600, P3D);
  background(255);
  //smooth(4); // Default is 2
  noSmooth();       
  //strokeWeight(1);
  }
  
void draw() 
  {
  background(255);
  fill(255, 0, 0);
  
  if(oddeven == 0)
    {
    stroke(0);
    rect(15, 20, 28, 30, 8, 8, 8, 8);
    
    noStroke();
    rect(15, 55, 28, 30, 8, 8, 8, 8);
    rect(15, 90, 28, 30);
    
    circle(30, 150, 30);
    }
  else
    {
    stroke(0);
    rect(15, 20, 29, 31, 9, 9, 9, 9);
    
    noStroke();
    rect(15, 55, 29, 31, 9, 9, 9, 9);
    rect(15, 90, 29, 31);
    
    circle(30, 150, 31);
    }
  
  img = get(mouseX-25, mouseY-25, 50, 50); // gets a rectangular section of image
  
  translate(100, 50);
  // Magnifies 20x
  int m = 10;
  stroke(128);
  for(int y = 0; y< img.height; y++)
    {
    for(int x = 0; x< img.width; x++)
      {
      int c = img.pixels[x+y*img.width];
      fill(c);
      rect(x*m, y*m, m, m);
      }
    }
  }
  
void keyPressed()
  {
  toggle = !toggle;
  
  if (toggle)
    {
    oddeven = 0; 
    println("odd");
    }
  else
    {
    oddeven = 1;
    println("even");
    }
  }

```

P2D and `noSmooth()`:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/e/8eed7d64be29be09ca15accbbf60491ab82ca49d.png)

I have experienced this before but don’t have an answer for this behavior.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/issue-when-rendering-small-rectangles/38217)._
