Expand description
An image drawn smaller is drawn from a level the core halves
(docs/adr/0044-an-image-drawn-smaller-is-drawn-from-a-level.md,
backlog V6).
Level 0 is the image; level n + 1 is level n with each 2×2 block
averaged into one texel, ⌈w/2⌉ × ⌈h/2⌉, the last row and column of
an odd size repeated. The average is taken in linear light with the
alpha premultiplied, so a level is neither darker than its source nor
fringed where a transparent edge meets colour. Which level a quad
draws is level_for: the deepest still at least as many texels as
pixels on both axes.
Functions§
- depth
- How many levels below level 0 a
w × himage has: halving stops at 1×1. - halve
- Level n + 1 from level n’s straight RGBA,
w × h × 4bytes: each 2×2 block averaged in linear light with the alpha premultiplied, the colour taken back to straight alpha. Returns the new size and pixels. - halved
- The size of the level below a
w × hone. - level_
for - The level a quad draws: the deepest whose texels still cover the
pixels on both axes.
texelsis the texel rectfitpicked at level 0,pixelsthe drawn size in physical px (any scale the quad is drawn through multiplied in),deepestthe chain’s last level.⌊log₂ r⌋forrthe smaller of the two ratios, so a bilinear sample inside the level minifies by less than two and a level never magnifies.