math on widths doesn't add up

hh hh at hyperhh.de
Sat Jun 15 03:53:20 EDT 2019


> Ralph D. wrote:
> You don't need sub-pixels per say but you need to know they exist.
> I found that out real quick when writing the color gradient math for
> CGI. If I did not use center pixel coordinates the gradients were
> "jaggy" so to speak.

"Use center pixel coordinates" does probably mean you use the math-loc
of a pixel as model? For example (always assume a linewidth of 1):

LC point (0,0) = rect (0,0,1,1) = first pixel has a math-loc of (0.5,0.5).
One imagines the pixel pinned up at its math-loc/center.
[I use the notation "math-loc" to avoid confusion with the rounded LC-loc.]

This is certainly in general a clear method for counting/ identifying
pixels. For example:

The rect (x1,y1,x2,y2) with x1<x2 and y1<y2 has (x2-x1)*(y2-y1) pixels.

The topleft pixel (x1,x2,x1+1,x2+1) = LC-point (x1,x2) is
math-located at (x1+0.5,x2+0.5) and
the bottomright pixel (x1-1,y2-1,x2,y2) = LC-point (x1-1,x2-1) is
math-located at (x2-0.5,y2-0.5).

The topleft of the first pixel is the math-point (x1,y1),
the bottomright of the last pixel is the math-point (x2,y2).




More information about the use-livecode mailing list