Skip to content

DrawBox - Kotlin Multiplatform Drawing SDKΒΆ

OverviewΒΆ

DrawBox is a lightweight drawing SDK built with Kotlin Multiplatform (KMP) and Jetpack Compose. It enables developers to embed editable drawing, annotation, diagramming, and export capabilities into Compose Multiplatform applications across Android, iOS, Desktop (JVM), and Web (WebAssembly) from a single, shared codebase.

Featured in Android Weekly, Android Arsenal, Kotlin Weekly, and Google Dev Library.

Key CapabilitiesΒΆ

Drawing ModesΒΆ

  • πŸ–ŠοΈ Freehand Drawing (Pen) - Create smooth, continuous paths
  • ⬜ Rectangle - Draw precise rectangular shapes
  • β­• Circle - Create perfect circles and ellipses
  • πŸ”Ί Triangle - Draw triangular shapes
  • ➜ Arrow - Create arrows with intelligent head sizing
  • βž– Line - Draw straight lines

Customization & ControlΒΆ

  • 🎨 Color Control - Set stroke color and background color
  • πŸ“ Stroke Width - Adjustable line thickness from 1px to any size
  • πŸ‘οΈ Opacity Control - Alpha transparency from 0.0 to 1.0
  • ↩️ Full Undo/Redo - Unlimited history tracking
  • πŸ”„ Reset Canvas - Clear all drawings instantly

Export & IntegrationΒΆ

  • πŸ“„ SVG Export - Export drawings as scalable vector graphics
  • πŸ–ΌοΈ PNG Export - Raster image export with bitmap support
  • πŸ“¦ JSON Serialization - Save/load drawing state for persistence
  • πŸ”Œ Embeddable SDK API - Simple Compose API with minimal setup

Why DrawBox?ΒΆ

Cross-Platform with Shared CodeΒΆ

Build once, deploy everywhere. Write your drawing logic once in Kotlin and run it natively on Android, iOS, Web, and Desktop.

Modern ArchitectureΒΆ

Uses the MVI (Model-View-Intent) pattern with immutable state management, making your code predictable, testable, and maintainable.

Production-Ready SDKΒΆ

  • Published on Maven Central
  • Actively maintained and battle-tested
  • Comprehensive documentation and examples
  • Used in production applications

Quick StatisticsΒΆ

Metric Value
Latest Version 2.1.0
Platforms Android, iOS, Web, Desktop
Architecture MVI Pattern
State Management Immutable, Functional
Export Formats SVG, PNG, JSON
License Apache 2.0

Technology StackΒΆ

Kotlin Multiplatform
β”œβ”€β”€ Android (Native)
β”œβ”€β”€ iOS (Native)
β”œβ”€β”€ JVM (Desktop)
└── WebAssembly (Web)

UI Framework: Jetpack Compose Multiplatform
Build System: Gradle (KTS)
State: MVI Pattern with sealed classes

Getting StartedΒΆ

Installation (2 minutes)ΒΆ

Add to your build.gradle.kts:

dependencies {
    implementation("io.ak1:drawbox:2.1.0")
}

Basic Usage (5 minutes)ΒΆ

@Composable
fun DrawingScreen() {
    val controller = rememberDrawBoxController()
    val state by controller.state.collectAsState()

    Column(Modifier.fillMaxSize()) {
        // Drawing canvas
        DrawBox(
            state = state,
            onIntent = controller::onIntent,
            modifier = Modifier
                .fillMaxSize()
                .weight(1f)
        )

        // Control panel
        ControlsBar(
            viewModel = controller,
            canUndo = /* ... */,
            canRedo = /* ... */,
            onModeSelected = { mode -> controller.setMode(mode) }
        )
    }
}

Features ComparisonΒΆ

Feature DrawBox Other Libraries
Multiplatform (KMP) βœ… ❌ Most are Android-only
Kotlin-First βœ… ❌ Some use Java
MVI Architecture βœ… ❌
SVG Export βœ… ⚠️ Partial support
Compose Native βœ… ❌
Undo/Redo βœ… βœ…
Multiple Shapes βœ… ⚠️ Limited
Web Support βœ… ❌

Documentation StructureΒΆ

Community & SupportΒΆ

  • πŸ™ GitHub Issues - Report bugs and request features
  • πŸ’¬ GitHub Discussions - Connect with other developers
  • πŸ“§ Email - Direct support and inquiries
  • β˜• Support Author - Buy the creator a coffee

LicenseΒΆ

DrawBox is licensed under the Apache License 2.0. See LICENSE for details.


Next StepsΒΆ

  1. Install DrawBox in your project
  2. Create your first drawing with our quick start guide
  3. Explore the API to unlock all capabilities
  4. Join the community and contribute improvements

Ready to embed drawing capabilities in your Compose Multiplatform project? Let's get started.