Strange pixels with point()

Drawing points with float positions doesn’t seem to round correctly in special situations.
It seems that sometimes two points are rendered instead of one.

  stroke(0);
  strokeWeight(3);
  point(10, 19.9999);
  point(15, 20);
  point(9.9999, 30);
  point(10, 35);

results in:

Very confusing. Any ideas?

Try noSmooth(); ?

Chrisir

Same result.
It also seems that the floats are not rounded to integer position.
When I change the value of 19.9999 to 19.999, I will get a single pixel, in the y-position of 19.

Hello,

The other renderers give different results:

void setup() 
  {
  size(640, 360, JAVA2D); //This is the default
  //size(640, 360, FX2D);
  //size(640, 360, P2D);
  //size(640, 360, P3D);
  stroke(0);
  strokeWeight(3);
  point(10, 19.9999);
  point(15, 20);
  point(9.9999, 30);
  point(10, 35);
  }

I can’t answer why but them a try!

:)

@chrisir @glv thanks for your answers.
I tried the other renderers, indeed different outputs.
The JAVA2D must have a bug: Why should there be a difference between the values of .9999 and .999 ?

1 Like