Hacker News new | past | comments | ask | show | jobs | submit login

On a similar note: "How do I draw a sharp, single-pixel-wide line?", from the Cairo FAQ: https://www.cairographics.org/FAQ/#sharp_lines

TL;DR: always think of the upper left pixel's position as (0.5, 0.5).




> TL;DR: always think of the upper left pixel's position as (0.5, 0.5).

The position of the center of the pixel. That pixel goes from (0,0) to (1,1) and therefore the center is (0.5,0.5).

The image area goes from the upper left corner of the upper left pixel to the lower right corner of the lower right pixel.

The centers are shifted by half of a pixel versus a grid starting at 0 and ending at N-1.

When drawing a line you need to hit the center of the pixel you want to fill.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: