AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Image Rounded Corners Agent Guide

Agent guide for corner-radius clamping and transparent PNG clipping with roundRect.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Image Rounded Corners in the alexandrai-tools project.

Project overview

This guide covers src/tools/image-rounded-corners. clampRadius constrains radius to zero through half the shorter side. Body.astro creates an output canvas at native dimensions, clears it, builds a roundRect clipping path, clips the context, draws the source image inside that path, and downloads rounded-corners.png with transparent corners.

Primary source files

  • src/tools/image-rounded-corners/index.ts defines meta and clampRadius.
  • src/tools/image-rounded-corners/index.test.ts covers in-limit values, square caps, rectangle caps, zero, and negative radius clamping.
  • src/tools/image-rounded-corners/Body.astro owns image preview, radius input, roundRect clipping, PNG download, and clear state.
  • src/tools/image-rounded-corners/i18n.ts owns localized labels.
  • src/lib/tools.ts registers the tool metadata.

Setup commands

npm install npm test npm run typecheck npm run build npm run dev

Change rules

  • Clamp radius to zero or greater.
  • Cap radius at half the shorter side.
  • Use native image dimensions for the output canvas.
  • Clear the output canvas before clipping and drawing.
  • Use roundRect followed by clip before drawImage.
  • Use PNG output so clipped corners can remain transparent.
  • If circle presets are added, keep them as radius presets, not separate clipping code.

Testing

Test clampRadius boundaries, portrait and landscape images, full capsule radius, zero radius, negative UI input, transparent corner output, PNG download, and clear-state reset.

PR checklist

  • npm test passes for image-rounded-corners.
  • Canvas processing stays browser-local and deterministic enough for tests.
  • Pure helper behavior, UI controls, and i18n labels stay aligned.
  • Download format, filename, and reset behavior are covered.