MCPcopy
hub / github.com/codeaashu/claude-code / roundCorners

Function roundCorners

src/utils/ansiToPng.ts:246–265  ·  view source on GitHub ↗

* Zero out the alpha channel in the four corner regions outside a * quarter-circle of radius `r`. Produces rounded-rect corners.

(
  px: Uint8Array,
  width: number,
  height: number,
  r: number,
)

Source from the content-addressed store, hash-verified

244 * quarter-circle of radius `r`. Produces rounded-rect corners.
245 */
246function roundCorners(
247 px: Uint8Array,
248 width: number,
249 height: number,
250 r: number,
251): void {
252 const r2 = r * r
253 for (let dy = 0; dy < r; dy++) {
254 for (let dx = 0; dx < r; dx++) {
255 const ox = r - dx - 0.5
256 const oy = r - dy - 0.5
257 if (ox * ox + oy * oy <= r2) continue
258 // Top-left, top-right, bottom-left, bottom-right.
259 px[(dy * width + dx) * 4 + 3] = 0
260 px[(dy * width + (width - 1 - dx)) * 4 + 3] = 0
261 px[((height - 1 - dy) * width + dx) * 4 + 3] = 0
262 px[((height - 1 - dy) * width + (width - 1 - dx)) * 4 + 3] = 0
263 }
264 }
265}
266
267// --- PNG encoding -----------------------------------------------------------
268

Callers 1

ansiToPngFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected