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).

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: Color, to: Color, lines: Color = Color(0xFF9DB4CF).copy(alpha = 0.10f))

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

Link copied to clipboard
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).

Link copied to clipboard
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: 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.

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

A filled rectangle.

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

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

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

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

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).

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

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