Package-level declarations

Types

Link copied to clipboard
data class SelectionChromeStyle(val padding: Dp = 6.dp, val handleSize: Dp = 11.dp, val cornerRadius: Dp = 8.dp, val strokeWidth: Dp = 1.5.dp, val accent: Color = Color(0xFF2196F3))

Visual configuration for the selection chrome — the accent-colored box and handles DrawBox paints around selected elements. All sizes are in Dp and stay a constant on-screen size regardless of zoom.

Functions

Link copied to clipboard
fun createPath(points: List<Offset>): Path
Link copied to clipboard

Decode an encoded image payload (PNG / JPEG / WebP) into an ImageBitmap usable by the renderer. Returns null if the bytes can't be decoded; the caller renders a placeholder instead of crashing. Implementations are platform-specific because the host graphics stack drives decoding:

Decode an encoded image payload (PNG / JPEG / WebP) into an ImageBitmap usable by the renderer. Returns null if the bytes can't be decoded; the caller renders a placeholder instead of crashing. Implementations are platform-specific because the host graphics stack drives decoding:

Decode an encoded image payload (PNG / JPEG / WebP) into an ImageBitmap usable by the renderer. Returns null if the bytes can't be decoded; the caller renders a placeholder instead of crashing. Implementations are platform-specific because the host graphics stack drives decoding:

Decode an encoded image payload (PNG / JPEG / WebP) into an ImageBitmap usable by the renderer. Returns null if the bytes can't be decoded; the caller renders a placeholder instead of crashing. Implementations are platform-specific because the host graphics stack drives decoding:

Shared between the js and wasmJs targets. Both run on top of Skiko for the canvas backend, so the encoded-bytes → ImageBitmap path is identical — org.jetbrains.skia.Image.makeFromEncoded(...).toComposeImageBitmap() works on both. Keeping a single actual here avoids the maintenance cost of two identical files and the risk of one drifting from the other.

Link copied to clipboard
actual fun decodeImageBitmapDownsampled(bytes: ByteArray, targetWidth: Int, targetHeight: Int): ImageBitmap?

Decode and downsample bytes to fit within targetWidth × targetHeight while preserving aspect ratio. The returned bitmap's longer side may be smaller than targetWidth / targetHeight if the shorter axis hits the cap first, but never larger.

expect fun decodeImageBitmapDownsampled(bytes: ByteArray, targetWidth: Int, targetHeight: Int): ImageBitmap?

Decode and downsample bytes to fit within targetWidth × targetHeight while preserving aspect ratio. The returned bitmap's longer side may be smaller than targetWidth / targetHeight if the shorter axis hits the cap first, but never larger.

actual fun decodeImageBitmapDownsampled(bytes: ByteArray, targetWidth: Int, targetHeight: Int): ImageBitmap?

Decode and downsample bytes to fit within targetWidth × targetHeight while preserving aspect ratio. The returned bitmap's longer side may be smaller than targetWidth / targetHeight if the shorter axis hits the cap first, but never larger.

actual fun decodeImageBitmapDownsampled(bytes: ByteArray, targetWidth: Int, targetHeight: Int): ImageBitmap?

Decode and downsample bytes to fit within targetWidth × targetHeight while preserving aspect ratio. The returned bitmap's longer side may be smaller than targetWidth / targetHeight if the shorter axis hits the cap first, but never larger.

actual fun decodeImageBitmapDownsampled(bytes: ByteArray, targetWidth: Int, targetHeight: Int): ImageBitmap?

Decode and downsample bytes to fit within targetWidth × targetHeight while preserving aspect ratio. The returned bitmap's longer side may be smaller than targetWidth / targetHeight if the shorter axis hits the cap first, but never larger.

Link copied to clipboard
fun DrawBox(state: State, onIntent: (Intent) -> Unit, modifier: Modifier = Modifier.fillMaxSize(), showGrid: Boolean = true, hiddenElementIds: Set<String> = emptySet(), overlay: @Composable BoxScope.() -> Unit = {}, selectionStyle: SelectionChromeStyle = SelectionChromeStyle.Default)

Main drawing canvas composable supporting both freehand drawing and geometric shapes.

Link copied to clipboard
fun DrawingPreview(elements: List<Element>, bgColor: Color, modifier: Modifier = Modifier.fillMaxSize(), viewport: Viewport = Viewport())

Render-only preview of a set of Elements. No gestures, no chrome, no grid. Useful for replay scrubbing, thumbnails, and read-only embeds.

Link copied to clipboard
actual fun encodeToPng(bitmap: ImageBitmap): ByteArray?

Encode an ImageBitmap as PNG bytes, or null if encoding fails. The inverse of decodeImageBitmap; used by io.ak1.drawbox.domain.usecase.PngExporter to turn a rasterized scene into a file-ready payload. Implementations are platform-specific because the host graphics stack drives encoding:

actual fun encodeToPng(bitmap: ImageBitmap): ByteArray?

Encode an ImageBitmap as PNG bytes, or null if encoding fails. The inverse of decodeImageBitmap; used by io.ak1.drawbox.domain.usecase.PngExporter to turn a rasterized scene into a file-ready payload. Implementations are platform-specific because the host graphics stack drives encoding:

actual fun encodeToPng(bitmap: ImageBitmap): ByteArray?

Encode an ImageBitmap as PNG bytes, or null if encoding fails. The inverse of decodeImageBitmap; used by io.ak1.drawbox.domain.usecase.PngExporter to turn a rasterized scene into a file-ready payload. Implementations are platform-specific because the host graphics stack drives encoding:

actual fun encodeToPng(bitmap: ImageBitmap): ByteArray?

Shared between the js and wasmJs targets — both run on Skiko, so the ImageBitmap → PNG-bytes path is identical. Mirrors decodeImageBitmap's single shared web actual to avoid two files drifting apart.