Skip to content

Compose binding

kiteqr-compose draws a BitMatrix onto a Compose Multiplatform surface. The core engine stays UI-free. Everything Compose-specific lives in this opt-in artifact.

Add it alongside the core:

implementation("io.github.yuroyami:kiteqr-compose:0.1.0")

It builds for fewer targets than the core, and its Android minSdk is 24 rather than 21. See Supported platforms before you add it.

The QrCode composable

import io.github.yuroyami.kiteqr.Qr
import io.github.yuroyami.kiteqr.compose.QrCode

@Composable
fun Ticket() {
    val matrix = remember { Qr.encode("TICKET-12345") }
    QrCode(
        matrix,
        modifier = Modifier.size(240.dp),
        dark = Color.Black,
        light = Color.White,
        quietZone = 4,
    )
}

It fills the modifier's bounds and stays square and centered. It merges adjacent dark modules into horizontal runs, so there are no anti-aliasing seams.

Drawing yourself

For a custom canvas, DrawScope.drawQrCode puts the symbol wherever you want:

Canvas(Modifier.fillMaxSize()) {
    drawQrCode(matrix, dark = brandColor, light = Color.Transparent)
}

An ImageBitmap

For Image(bitmap = ...), sharing, or saving, rasterize to an ImageBitmap:

import io.github.yuroyami.kiteqr.compose.toImageBitmap

val bitmap = remember { Qr.encode("hello").toImageBitmap(scale = 8) }
Image(bitmap, contentDescription = "QR code")