# A Processing precision problem?

**URL:** <https://discourse.processing.org/t/a-processing-precision-problem/34693>\
**Category:** Beginners\
**Created:** [January 17, 2022, 5:06pm UTC](https://discourse.processing.org/t/a-processing-precision-problem/34693 "2022-01-17T17:06:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coderambler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/coderambler/32/15464_2.png) [@coderambler](https://discourse.processing.org/u/coderambler)\
**Post date:** [January 17, 2022, 5:06pm UTC](https://discourse.processing.org/t/a-processing-precision-problem/34693/1 "2022-01-17T17:06:47Z")

</div>

The code example below inscribes a circle within a square.  
In the result however, the circle is moved one point up and one point left, relative to the square.  
Check the picture: The borderless circle is tipping over the center of the left and up boundaries of the square, while staying clean of the right and bottom ones.

I tried to change the radius and the center, to use rounded coordinates, etc. yet the effect persists.

**Q** : Am I doing anything wrong? Otherwise how to address this issue “cleanly”?

The code:

```
size (500,500);

PVector center = new PVector(width/2,height/2);
float radius = 200;

rectMode(RADIUS);
ellipseMode(RADIUS);

fill(#EEEEEE);
strokeWeight(1);
rect(center.x,center.y,radius,radius);

noStroke();
fill(#FFFFFF);
circle(center.x,center.y,radius);

stroke(0);
line(center.x-250,center.y,center.x+250,center.y);
line(center.x,center.y-250,center.x,center.y+250);

```

The effect:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/079de0b4c26b182326f2356ed53d745369942970.png)

---

<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:** [January 17, 2022, 5:22pm UTC](https://discourse.processing.org/t/a-processing-precision-problem/34693/2 "2022-01-17T17:22:07Z")

</div>

Hello,

This example may help:

```auto
size (500, 500);

float dia;

PVector center = new PVector(width/2, height/2);

// Try ones of these 4 at a time:

// 1 left + top
dia = 400;
smooth(3); //default

// 2 ok
//dia = 400;
//noSmooth();

// 3 ok
//dia = 401; 
//smooth(3); //default

// 4 right + bottom
//dia = 401; 
//noSmooth();

rectMode(CENTER);
ellipseMode(CENTER);

fill(#EEEEEE);
strokeWeight(1);
rect(center.x, center.y, dia, dia);

noStroke();
fill(#FFFFFF);
circle(center.x, center.y, dia);

stroke(0);
line(center.x-250, center.y, center.x+250, center.y);
line(center.x, center.y-250, center.x, center.y+250);

```

I have had these issues before and have to adjust to lining up to pixels sometimes.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8176818c9eb51620a7ccf21951bd63c9152490a3.png)

You can also try another renderer with your code:  
[https://processing.org/reference/size\_.html](https://processing.org/reference/size_.html)

See the references about _smooth()_ and _noSmooth()_:  
[https://processing.org/reference/noSmooth\_.html](https://processing.org/reference/noSmooth_.html)  
[https://processing.org/reference/smooth\_.html](https://processing.org/reference/smooth_.html)

This also seemed to _work_ with your original code:  
`float radius = 200.5;`

I do not have a definitive solution and was experimenting a bit.

I suspect it is related to smoothing and anti-aliasing.

`:)`

---

<div class="post-metadata">

**Author:** ![coderambler](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/coderambler/32/15464_2.png) [@coderambler](https://discourse.processing.org/u/coderambler)\
**Post date:** [January 18, 2022, 5:45pm UTC](https://discourse.processing.org/t/a-processing-precision-problem/34693/3 "2022-01-18T17:45:33Z")

</div>

glv, I appreciate the quick, detailed and experimented reply.  
Like you, I suspect it is an artifact of the renderer. Thanks to your suggestion, it’s proven: Using “size(500,500,P3D)” does avoid the artifact, at least in the original case. Now I know it’s not my fault 🙂  
Thank you!
