def cover.brush
gralha-svg-render@0.1.0.1 · svg.bend:4352
import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
4352
4353
4354def cover.brush(brush: Brush, +m: Matrix, +frame: Raster, +sub: U32, cover: List<&2, Scene<Brush>> -> Raster -> U32 -> List<&2, Scene<Brush>>) -> Brush:
4355 match brush:
4356 case Bitmap{raster, inv, nearest}:
4357 +matrix = inv
4358 cover.bitmap(raster, matrix, nearest, cover.axes(matrix.mul(m, matrix.inverse(matrix)), frame))
4359 case Solid{c, source}: Solid{c, source}
4360 case PendingContext{stroke, opacity}: PendingContext{stroke, opacity}
4361 case ContextPaint{source, mat, opacity}:
4362 +matrix = mat
4363 ContextPaint{cover.brush(source, matrix.mul(m, matrix.inverse(matrix)), frame, sub, cover), matrix, opacity}
4364 case Pattern{inv, w, h, opacity, nodes}:
4365 +matrix = inv
4366 +ww = w
4367 +hh = h
4368 +pm = matrix.mul(m, matrix.inverse(matrix))
4369 +density = cover.density(pm, frame)
4370 +direct = cover.aligned(pm) && F32.is_ge((U.min(ww, hh) * density : F32), 4.0)
4371 +tile = cover.tile.frame(ww, hh, U.choose(F32, direct, density, U.max((density * U32.to_f32(sub) : F32), (4.0 / U.max(U.min(ww, hh), 0.000001) : F32))))
4372 +back = matrix.inverse(pm)
4373 +st = raster.scale(frame)
4374 Tile{cover.tile(tile, cover(nodes)(tile)(sub), ww, hh), matrix, ww, hh, opacity, cover.vector(back, st, 0.0), cover.vector(back, 0.0, st), U.choose(U32, direct, 1, sub)}
4375 case Tile{raster, inv, w, h, opacity, u, v, grid}: Tile{raster, inv, w, h, opacity, u, v, grid}
4376 case Gradient{inv, radial, start, end, radius, focal, stops, spread, opacity, linear}: Gradient{inv, radial, start, end, radius, focal, stops, spread, opacity, linear}