A React-based drawing tool that allows users to create pixel art and geometric patterns on a grid. The tool supports both square pixels and triangular subdivisions, making it perfect for creating pixel art, isometric designs, and geometric patterns.
- 26x26 grid with adjustable pixel size
- Two drawing modes:
- Square pixels (black or clear)
- Triangular subdivisions (black triangles in one of four corners)
- Export capabilities:
- PNG export
- SVG export
- JSON export
- Import capabilities:
- JSON import
- PNG import (overlay only)
- Keyboard shortcuts for quick access to features
- Real-time preview
- Pixel size adjustment
- Background color customization
- Invert colors functionality
Z: Draw black pixelX: Clear pixel (erase)Q: Draw black triangle in bottom-right cornerW: Draw black triangle in bottom-left cornerA: Draw black triangle in top-right cornerS: Draw black triangle in top-left corner
- Clone the repository:
git clone https://github.com/kylemcdonald/tricon.git
cd tricon- Install dependencies:
npm installTo start the development server:
npm run devThis will run the app in development mode. Open http://localhost:5173 to view it in your browser.
To create a production build:
npm run buildThe build artifacts will be stored in the dist/ directory.
The project is configured for GitHub Pages deployment. To deploy:
npm run deployThis will build the project and deploy it to GitHub Pages.
The grid drawing tool is built using React, TypeScript, and Vite. The main components are:
- Grid Manager: A class that handles grid state and updates
- Canvas: A canvas element that renders the grid and handles drawing interactions
- Drawing State: Manages the current drawing mode and triangle orientation
- Export Functions: Convert the grid state to various formats (PNG, SVG, JSON)
The tool uses Bresenham's line algorithm for smooth line drawing when dragging the mouse across multiple pixels. The drawing state is managed using React's useState hook, and the grid is represented as a 2D array of pixel objects.
This project is open source and available under the MIT License.