class

ContributorMural::Renderers::Voronoi

Inherits ContributorMural::Renderer < Reference < Object

Stained glass: avatars clipped into irregular cells that tile a rectangle edge to edge, separated by a hairline lead. Seeds sit on a jittered lattice, and each cell is the block rectangle cut down by one half-plane per other seed — a power (Laguerre) diagram, so weight widens a cell without moving it.

The lead is a true inset rather than a stroke: pulling every cutting line back by half the gap leaves neighbouring cells exactly gap apart with the page showing through, which themes itself for free under a transparent background.

Constants

ALPHA_MAX = 0.5

Cap on how far weight may push a boundary, as a fraction of the closest seed pair. At 0.5 every cell provably still contains a disc of radius 0.25 * d_min around its own seed, so no cell can be squeezed to nothing however lopsided the weights are (see the "no cell collapses" spec).

BISECTOR_REACH = 0.4

Second guard on the same invariant, expressed where it is easiest to read: the boundary between two seeds may never travel past 70% of the way toward either of them.

CLIP_PREFIX = "vcell-"

These ids land in a generated file that consumers run spell checkers over, so the prefix has to stay clear of dictionary near-misses: an abbreviation of "voronoi" reads as a misspelling of "for" to crate-ci/typos, once per cell, in a file nobody can correct by hand.

MIN_REACH = (1.0 - BISECTOR_REACH) / 2.0

The closest a boundary can come to its own seed, as a fraction of the distance to the other one — the near end of the interval BISECTOR_REACH pins down. This is what lets a cell rule a distant seed out without clipping against it.

Instance methods

fetch_size(user : ResolvedUser) : Int32

Pixel size at which to fetch this user's avatar (2x render size for crisp display on high-DPI screens).

Source
prepare(users : Array(ResolvedUser)) : Nil

Dense rank over the distinct weight values, not over users: a contributor with 1000x the commits lands at the top of the scale exactly like one with 2x, so an outlier can never distort the geometry. All-equal weights leave the table empty, which reduces to a plain Voronoi.

Source