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

NameTypeNotes
slots{center: PropRef}

Example

const {dist} = centredFrame({center: p('center')})(params, surfaceOf(params))

Tip. dist is 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: its uv, its viewport size in pixels and its aspect.
  • rawSurfaceOf — The canvas like surfaceOf, but always measured against the whole canvas, never a fitted box.

Used by

Blob