Expand description
Shapes in whole console pixels, by one integer rule every renderer
follows (ADR-0085 §8): each gives its pixels as runs, and a renderer
fills each run as a rectangle one console pixel high. So shuyi-app,
the raster and the one-bit renderers draw the same pixels by
construction.
The rules, in console pixels, integers only. A point names a pixel:
(x, y) is that pixel’s centre.
- A line one pixel wide (
line_runs) is Bresenham’s, fromfromtoto, both ends drawn: the all-octant form whose error term starts atdx + dy(dx = |x1 − x0|,dy = −|y1 − y0|). Along its major axis (xwhen|dx| ≥ |dy|) it takes one pixel a step; pixelkfromfromisround(k · minor / major)along the other, a half rounded towardsto. That closed form gives the pixels of the walk, so a line far longer than the clip costs no more than the clip: only the steps inside it are taken. - A circle’s outline of radius
r(circle_outline_runs) is2r + 1pixels across: the midpoint circle whose decision value starts at1 − r, one octant walked (at mostrsteps), each step giving its eight mirrored pixels.
A run is (y, x0, x1): row y, pixels x0..x1, half-open, always
inside the clip. Runs may overlap (a circle’s mirrored pixels where the
octants meet); every renderer paints them opaque, so that doesn’t
matter.
Functions§
- circle_
outline_ runs - Calls
f(y, x0, x1)for the runs of the outline of the circle ofradiusroundcenterinsideclip(the module’s rule): one pixel a run. - line_
runs - Calls
f(y, x0, x1)for the runs of the line one pixel wide fromfromtoto, both ends drawn, insideclip(the module’s rule). Each row of the line is one run.