Skip to content

Add circle tool#329

Open
bertyhell wants to merge 3 commits intolewish:mainfrom
bertyhell:feat/circle-tool
Open

Add circle tool#329
bertyhell wants to merge 3 commits intolewish:mainfrom
bertyhell:feat/circle-tool

Conversation

@bertyhell
Copy link

@bertyhell bertyhell commented Jun 4, 2025

This PR adds a basic implementation of a circle tool:
circle

google-labs-jules bot and others added 3 commits June 4, 2025 19:00
This commit introduces a new circle drawing tool to Asciiflow.

The circle tool allows you to draw circles by clicking for the center point and dragging to define the radius. The circle is rendered using specific ASCII characters for its different segments:
- '-' for top and bottom sides
- '|' for left and right sides
- '/' for top-left and bottom-right diagonals
- '\' for top-right and bottom-left diagonals

Key changes include:
- A new `DrawCircle` class in `client/draw/circle.ts` implementing the drawing logic.
- Addition of `ToolMode.CIRCLE` to the `ToolMode` enum.
- Registration of the new tool in the application's store.
- Integration of the circle tool into the UI drawer, including an icon, tool selection button, and help text.
- Implementation of an `alt + 7` keyboard shortcut to activate the circle tool.
This commit incorporates your feedback to improve the circle drawing tool:

1.  **Aspect Ratio Compensation**: The circle drawing logic now accounts for the non-square aspect ratio of characters (approx. 2:1 height:width). This is achieved by drawing an ellipse in the character grid that appears visually as a round circle.

2.  **Line Thickness and Connectivity**: The algorithm for selecting cells to draw on has been tuned to prioritize visual connectivity while aiming for a line that is predominantly one character thick. A tolerance factor of 0.75 is used in distance calculations.

3.  **Character Selection by Angular Sectors**: Character selection ('|', '-', '/', '\') is now based on 8 precise angular sectors around the circle, as specified, ensuring more accurate visual representation. Angles are calculated using aspect-ratio-compensated coordinates.

4.  **Toolbar Adjustments**:
    - The "Circles" tool button in the toolbar has been moved to appear directly below the "Boxes" tool.
    - The tool name has been updated from "Circle" to "Circles" for consistency.
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.

1 participant