Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Extends the library with two commonly needed capabilities: adding borders/padding to images and drawing basic geometric primitives.

Border Methods

  • border(width, r, g, b, a) - uniform border on all sides
  • borderSides(top, right, bottom, left, r, g, b, a) - asymmetric borders
  • Increases dimensions accordingly, preserves metadata (DPI, physical dimensions)

Drawing Primitives

  • drawLine(x0, y0, x1, y1, r, g, b, a) - Bresenham's algorithm for pixel-perfect lines
  • drawCircle(cx, cy, radius, r, g, b, a, filled) - Midpoint circle algorithm with fill option
  • Automatic bounds clipping, RGBA support including transparency

Example

const canvas = Image.create(400, 300, 255, 255, 255);

// Draw shapes
canvas
  .drawCircle(100, 100, 50, 255, 0, 0, 255, true)  // filled red circle
  .drawLine(0, 0, 400, 300, 0, 0, 255)              // blue diagonal
  .border(20, 0, 0, 0);                              // 20px black border

await Deno.writeFile("output.png", await canvas.encode("png"));

All methods follow the chainable API pattern. Test coverage: 18 new tests, 393 total passing.

Original prompt

Identify and implement the two best new features for the library. Consider both extending existing features of adding new.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 10, 2025 17:16
Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add two new features to extend library functionality Add border and drawing primitives (lines, circles) to image manipulation API Dec 10, 2025
Copilot AI requested a review from Hexagon December 10, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants