centredFrame
A frame centred on a position prop: each pixel's offset from the centre and its distance.
centredFrame(slots: {center: PropRef}): (params: GpuFragmentParams, surface: { uv: Expr; aspect: Expr; }) => CentredFrame
Import frames from shaders/std and use frames.centredFrame.
Pass {center: p('center')} where center is a position prop. Call the result with params and a surface. Distances are aspect-corrected, so 1 is the canvas height and a circle stays round on a wide canvas.
Parameters
| Name | Type | Notes |
|---|---|---|
slots | {center: PropRef} |
Example
const {dist} = centredFrame({center: p('center')})(params, surfaceOf(params))
Tip.
distis in canvas-height units: a radius of 0.5 reaches the top and bottom edges from the middle.
See also
segmentFrame— A frame along the line between two position props: how far each pixel is along it and across it.surfaceOf— The canvas a generator paints on: itsuv, itsviewportsize in pixels and itsaspect.rawSurfaceOf— The canvas likesurfaceOf, but always measured against the whole canvas, never a fitted box.