CardCanvas

The drawing surface handed to a CardFace: plain Compose drawing (scope) plus text helpers, so faces can lay out text without platform code. Sizes are in card pixels (1024×646).

Every helper comes in two forms that draw identically: one with Compose types (Color, TextStyle, TextUnit; Kotlin only) and one with plain values — colours as ARGB Longs (0xAARRGGBB, see CardColors), text sizes as Floats and weights as CardTextWeight — which is the one Swift sees.

Properties

Link copied to clipboard
Link copied to clipboard

Raw Compose drawing, for anything the helpers don't cover.

Link copied to clipboard

Functions

Link copied to clipboard
fun background(from: Long, to: Long)

background with ARGB colours and the default guilloche lines.

fun background(from: Color, to: Color, lines: Color = Color(0xFF9DB4CF).copy(alpha = 0.10f))

A soft diagonal gradient over the whole card plus fine guilloche lines.

fun background(from: Long, to: Long, lines: Long)

background with ARGB colours (0xAARRGGBB), lines included.

Link copied to clipboard
fun field(x: Float, y: Float, label: String, value: String?)

field at the default size (26) and colours.

fun field(x: Float, y: Float, label: String, value: String?, valueSize: Float)

field with the value at valueSize card pixels, in the default colours.

fun field(x: Float, y: Float, label: String, value: String?, valueSize: TextUnit = 26.sp, valueColor: Color = CardInk, labelColor: Color = CardMuted)

A small uppercase-style label with its value below ("—" when missing).

fun field(x: Float, y: Float, label: String, value: String?, valueSize: Float, valueColor: Long, labelColor: Long)

field with the value at valueSize card pixels and ARGB colours (0xAARRGGBB).

Link copied to clipboard
fun image(bytes: ByteArray, x: Float, y: Float, w: Float)

image at its own aspect ratio, square corners, fully opaque.

fun image(bytes: ByteArray, x: Float, y: Float, w: Float, h: Float)

image scaled to w × h, square corners, fully opaque.

fun image(bytes: ByteArray, x: Float, y: Float, w: Float, h: Float? = null, cornerRadius: Float = 0.0f, alpha: Float = 1.0f, grayscale: Boolean = false)

An image (PNG/JPEG bytes) at (x, y), w wide; h defaults to keeping the aspect ratio. cornerRadius rounds the corners, alpha / grayscale make a faded "ghost" copy (a common security-print look). Undecodable bytes are skipped.

Link copied to clipboard
fun radialBackground(center: Long, edge: Long)

radialBackground with ARGB colours and the default white print.

fun radialBackground(center: Color, edge: Color, pattern: Color = Color.White.copy(alpha = 0.35f))

A radial gradient (center colour in the middle radiating to edge) plus a fine woven print: two diagonal line sets and a lattice of small rings, all in pattern. The security-print look of many national ID cards.

fun radialBackground(center: Long, edge: Long, pattern: Long)

radialBackground with ARGB colours (0xAARRGGBB), pattern included.

Link copied to clipboard
fun rect(color: Color, x: Float, y: Float, w: Float, h: Float)

A filled rectangle.

fun rect(color: Long, x: Float, y: Float, w: Float, h: Float)

A filled rectangle in an ARGB colour (0xAARRGGBB).

Link copied to clipboard
fun text(text: String, x: Float, y: Float, style: TextStyle)

Text with its top-left at (x, y).

fun text(text: String, x: Float, y: Float, size: Float, weight: CardTextWeight, color: Long)

text without letter spacing.

fun text(text: String, x: Float, y: Float, size: Float, weight: CardTextWeight = CardTextWeight.Regular, color: Long = CardColors.ink, letterSpacing: Float = 0.0f)

Text with its top-left at (x, y): size in card pixels, weight, color as ARGB (0xAARRGGBB), letterSpacing in card pixels (0 = the typeface's own).

Link copied to clipboard
fun textCenter(text: String, centerX: Float, y: Float, style: TextStyle)

Text centred on centerX (same box technique as textRight).

fun textCenter(text: String, centerX: Float, y: Float, size: Float, weight: CardTextWeight, color: Long)

textCenter without letter spacing.

fun textCenter(text: String, centerX: Float, y: Float, size: Float, weight: CardTextWeight = CardTextWeight.Regular, color: Long = CardColors.ink, letterSpacing: Float = 0.0f)

Text centred on centerX (see textCenter); size, weight, color and letterSpacing as in text.

Link copied to clipboard
fun textRight(text: String, rightX: Float, y: Float, style: TextStyle)

Text right-aligned to rightX: laid out in a fixed box spanning 0..rightX with absolute right alignment rather than offset by a measured width (see the note on constraints below).

fun textRight(text: String, rightX: Float, y: Float, size: Float, weight: CardTextWeight, color: Long)

textRight without letter spacing.

fun textRight(text: String, rightX: Float, y: Float, size: Float, weight: CardTextWeight = CardTextWeight.Regular, color: Long = CardColors.ink, letterSpacing: Float = 0.0f)

Text right-aligned to rightX (see textRight); size, weight, color and letterSpacing as in text.

Link copied to clipboard

The width text takes in style, for laying out inline label + value pairs.

fun textWidth(text: String, size: Float, weight: CardTextWeight = CardTextWeight.Regular, letterSpacing: Float = 0.0f): Float

The width text takes at size and weight (with letterSpacing), for inline label + value pairs.