def raster.format
gralha-svg-render@0.1.0.1 · svg.bend:4018
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
import gralha-image@0.1.0.1/image.bend as Img
4018def raster.format(box: Bounds, requested: F32) -> Raster:
4019 Bounds{x0, y0, x1, y1} = box
4020 +x = x0
4021 +y = y0
4022 +right = x1
4023 +bottom = y1
4024 +step = U.max(U.max(requested, 0.000001), (U.max((right - x : F32), (bottom - y : F32)) / 1022.0 : F32))
4025 +ox = (F32.floor((x / step : F32)) * step : F32)
4026 +oy = (F32.floor((y / step : F32)) * step : F32)
4027 +w = F32.to_u32(U.clamp(F32.ceil(((right - ox) / step : F32)), 0.0, 1024.0))
4028 +h = F32.to_u32(U.clamp(F32.ceil(((bottom - oy) / step : F32)), 0.0, 1024.0))
4029 Raster{Point{ox, oy}, step, w, h, raster.depth(U.choose(U32, U32.is_gt(w, h), w, h), 1, 0n), False{}, Img.Flat{Img.clear()}}