Skip to content

Add Custom Brushes to Bitmap Editor (Procreate-style) #12

@coderabbitai

Description

@coderabbitai

🎨 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

  1. 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
  2. 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
  3. 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

  1. Data Structure

    {
      name: 'Soft Round',
      image: Image/Canvas with brush stamp,
      defaultSize: 20,
      defaultSpacing: 0.25, // fraction of brush size
      supportsRotation: false,
      textured: false
    }
  2. 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
  3. 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
  4. 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

  1. New Files:

    • src/helper/bit-tools/bit-custom-brush-tool.js - Main brush tool
    • src/helper/brushes/brush-engine.js - Brush stamping logic
    • src/helper/brushes/brush-presets.js - Default brush definitions
    • src/components/brush-selector/ - UI for brush selection
    • assets/brushes/ - Brush stamp images (PNG)
  2. Modify:

    • src/lib/modes.js - Add custom brush mode
    • Bitmap tool UI to show brush options

User Stories

  1. As a digital artist, I want to select different brush types so that I can create varied textures in my artwork
  2. As a user, I want to adjust brush size and opacity so that I can control the intensity of my strokes
  3. As a tablet user, I want pressure-sensitive brushes so that I can create natural-looking strokes
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions