-
Notifications
You must be signed in to change notification settings - Fork 1
Description
🎨 Feature Request: Custom Brushes for Bitmap Editor
Context
The bitmap editor has been underutilized compared to the vector editor. While vector has received significant attention and features over the years, the bitmap editor deserves its time to shine! Many users prefer tools like Procreate specifically because of their powerful brush system.
Proposed Feature
Implement a custom brush system for the bitmap editor that uses prerendered raster images as brush stamps, similar to Procreate's brush engine.
Technical Approach
Core Brush System
-
Brush Stamp Loading
- Load prerendered raster images (PNG with alpha channel) as brush stamps
- Support multiple brush presets (soft round, hard round, textured, etc.)
- Store brushes in a brushes library/folder
-
Brush Engine
- Stamp the brush image along the stroke path at regular intervals
- Interpolate between points for smooth strokes
- Apply spacing based on brush size
- Support pressure sensitivity (if available from input device)
- Handle brush rotation and scale
-
Brush Properties
- Size: Scale the brush stamp
- Opacity: Alpha blending for the stamp
- Spacing: Distance between stamps along stroke path
- Hardness: Edge softness (could blur the stamp)
- Rotation: Angle of the stamp (static or dynamic)
- Jitter: Randomize size, opacity, rotation for natural effects
Implementation Details
-
Data Structure
{ name: 'Soft Round', image: Image/Canvas with brush stamp, defaultSize: 20, defaultSpacing: 0.25, // fraction of brush size supportsRotation: false, textured: false }
-
Stroke Algorithm
- On mouse/touch down: stamp at initial point
- On mouse/touch move:
- Calculate distance from last stamp point
- If distance > spacing threshold, stamp along path
- Use line interpolation to place stamps evenly
- Apply current color and opacity to stamp
-
Brush Presets to Include
- Soft Round (default)
- Hard Round (sharp edges)
- Airbrush (soft, scattered)
- Flat Brush (rectangular)
- Textured brushes (canvas, paper, chalk)
- Splatter brush
- Calligraphy brush
-
UI Components
- Brush picker/selector (dropdown or sidebar)
- Brush size slider
- Opacity slider
- Spacing control (advanced)
- Brush preview circle
Technical Considerations
-
Performance: Canvas drawImage() is fast, but many stamps might slow down
- Consider using requestAnimationFrame for smooth rendering
- Batch draw operations when possible
- Use offscreen canvas for brush stamp cache
-
Memory: Preload all brush stamps at startup or lazy load
-
Pressure Sensitivity: WebAPI Pointer Events provide pressure data
event.pressure // 0.0 to 1.0
-
Blend Modes: Support different blend modes for stamps (normal, multiply, screen, etc.)
Files to Modify/Create
-
New Files:
src/helper/bit-tools/bit-custom-brush-tool.js- Main brush toolsrc/helper/brushes/brush-engine.js- Brush stamping logicsrc/helper/brushes/brush-presets.js- Default brush definitionssrc/components/brush-selector/- UI for brush selectionassets/brushes/- Brush stamp images (PNG)
-
Modify:
src/lib/modes.js- Add custom brush mode- Bitmap tool UI to show brush options
User Stories
- As a digital artist, I want to select different brush types so that I can create varied textures in my artwork
- As a user, I want to adjust brush size and opacity so that I can control the intensity of my strokes
- As a tablet user, I want pressure-sensitive brushes so that I can create natural-looking strokes
- As an artist, I want textured brushes so that I can simulate traditional media (pencil, chalk, paint)
Success Criteria
- Users can select from at least 5 different brush presets
- Brush size and opacity are adjustable in real-time
- Strokes appear smooth with proper stamp spacing
- Performance remains smooth even with large brushes
- Brushes support alpha blending correctly
- UI is intuitive and doesn't clutter the existing interface
Future Enhancements (Post-MVP)
- Custom brush creation/import from user images
- Brush dynamics (size/opacity varying with speed or direction)
- Advanced scatter and texture options
- Brush library management (save/load custom brushes)
- Shape dynamics (rotation based on stroke direction)
- Dual brush (combine two brush stamps)
References
Related Issue
Mentioned in #11
Backlink: Requested by @supervoidcoder in #11