MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / cornerAlpha

Function cornerAlpha

packages/engine/src/utils/alphaBlit.ts:367–374  ·  view source on GitHub ↗

Anti-aliased alpha for a point at distance `dist` from a corner circle of radius `r`.

(px: number, py: number, cx: number, cy: number, r: number)

Source from the content-addressed store, hash-verified

365
366/** Anti-aliased alpha for a point at distance `dist` from a corner circle of radius `r`. */
367function cornerAlpha(px: number, py: number, cx: number, cy: number, r: number): number {
368 const dx = px - cx;
369 const dy = py - cy;
370 const dist = Math.sqrt(dx * dx + dy * dy);
371 if (dist > r + 0.5) return 0;
372 if (dist > r - 0.5) return r + 0.5 - dist;
373 return 1;
374}
375
376/**
377 * Compute the alpha (0.0–1.0) for a point inside a rounded rectangle.

Callers 1

roundedRectAlphaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected