Chitra Lekhan
An Android library for image annotation built using Jetpack Compose and Canvas API
✨ Features
- Freehand and shape-based drawing
- Undo/Redo/Clear support
- Configurable brush color and size
- Zoom and pan gestures
- Easy-to-use toolbar component
- Jetpack Compose integration
📦 Installation
Kotlin (build.gradle.kts)
dependencies {
implementation("com.github.karya-inc:chitralekhan:<latest_release>")
}
Groovy (build.gradle)
dependencies {
implementation 'com.github.karya-inc:chitralekhan:<latest_release>'
}
🚀 Usage
Step 1: Create an instance
val chitraLekhan = rememberChitraLekhan(
image = bitmap,
drawMode = DrawMode.FreeHand,
color = colors.random(),
width = 1f
)
Step 2: Call the canvas composable
ChitraLekhanCanvas(
chitraLekhan = chitraLekhan,
modifier = Modifier.fillMaxSize()
)
Step 3: Add optional toolbar
var isColorPickerVisible by remember { mutableStateOf(false) }
ChitraLekhanToolbar(
colors = colors,
pickedColor = chitraLekhan.strokeColor.value,
isColorPickerVisible = isColorPickerVisible,
onColorPickerClicked = { isColorPickerVisible = !isColorPickerVisible },
onColorPicked = {
chitraLekhan.setColor(it)
isColorPickerVisible = false
},
drawMode = chitraLekhan.drawMode.value,
onDrawModeSelected = chitraLekhan::setDrawMode,
onClear = chitraLekhan::clear,
onUndo = chitraLekhan::undo,
onRedo = chitraLekhan::redo,
modifier = Modifier
.clip(RoundedCornerShape(16.dp, 16.dp, 0.dp, 0.dp))
.background(MaterialTheme.colorScheme.surfaceContainer)
.padding(8.dp),
brushSize = chitraLekhan.strokeWidth.value,
onBrushSizeChange = chitraLekhan::setWidth
)
⚙️ Available Configurations
📱 Sample App
Check out the Sample App for a working example.
🙏 Acknowledgements
Inspired by:
- DrawFull
- Image Annotation Tool for Karya Android App