How little can you slice an HTML5 canvas pixel?

In Flash, pixels are computed using twips or a twentieth pixel. Therefore, each position is always a multiple of 0.05. I have not seen this in the HTML Canvas specification and cannot track the cursor position on the Canvas. Does anyone know the accuracy of its pixel calculations?

Edit for clarification:

I mean more the Zeno paradox , which says, to move something from point A to point B, you first need to go to halfway between them. And then halfway to infinity.

So, if I want to move along the x axis from point 0 to 100 at 0.5:

  • In the frame 1: 50
  • Frame 2: 75
  • Shot 3: 87.5
  • Then: 93.75, 96.875, 98.4375 ... etc.

So, at what stage is the Canvas actually rounded to the next pixel?

+6
source share
1 answer

I'm not sure what you mean by precise slicing.

The pixels on the canvas can be drawn a little less than 0.10, after which they see almost nothing.

Of course, if you scale, you can draw what is 0.00125 pixels, and so on. But they will not be visible if you do not weaken.

http://jsfiddle.net/GvVD9/

(This first square block in the upper left corner is a pixel)

Mouse accuracy is another thing entirely unrelated to the canvas spec.

EDIT:

Well, we can demonstrate this. We can draw a bunch of pixels with y values โ€‹โ€‹approaching 100, and see how they compare with the red pixel drawn with y value 100.

http://jsfiddle.net/GvVD9/46/

Each individual part, horizontally divided, represents just one 1 in 1 pixel using the drawRect command.

50 75 87.5 93.75 // first black pixel you see in image 96.875 98.4375 99.21875 99.609375 99.8046875 99.90234375 99.951171875 99.9755859375 99.98779296875 99.993896484375 99.9969482421875 // last black pixel you see in image 

enter image description here

+4
source

Source: https://habr.com/ru/post/887166/


All Articles