Image

data class Image(val id: String = Uuid.random().toString(), val type: String = "Image", val bytes: ByteArray, val intrinsicSize: Size, val points: List<Offset>, val opacity: Float = 1.0f, val zIndex: Int = 0, val rotation: Float = 0.0f, val createdAt: Long = 0, val modifiedAt: Long = 0) : Element

Bitmap element placed on the canvas. bytes is the raw encoded payload (PNG / JPEG / WebP) and the source of truth — the renderer decodes it into an androidx.compose.ui.graphics.ImageBitmap on demand and caches the result keyed by id. Resize / rotate / move / select reuse the standard two-point AABB infrastructure.

Constructors

Link copied to clipboard
constructor(id: String = Uuid.random().toString(), type: String = "Image", bytes: ByteArray, intrinsicSize: Size, points: List<Offset>, opacity: Float = 1.0f, zIndex: Int = 0, rotation: Float = 0.0f, createdAt: Long = 0, modifiedAt: Long = 0)

Properties

Link copied to clipboard

Raw encoded image bytes; never decoded until rendered.

Link copied to clipboard
open override val createdAt: Long

Epoch milliseconds at which this element was first created. Used for ordered replay (and later as a tie-break source for collab clocks). 0L means "unknown" — element predates the timestamp field; consumers that sort by createdAt should treat 0 as "earliest".

Link copied to clipboard
open override val id: String

Unique identifier for this element

Link copied to clipboard

Pixel dimensions of the source image, used to preserve aspect ratio on initial placement and to drive SVG export's width / height attributes.

Link copied to clipboard
open override val modifiedAt: Long

Epoch milliseconds at which any property of this element last changed. On creation, equals createdAt. Bumped via touched on every mutation path so sync layers can resolve concurrent edits with LWW semantics.

Link copied to clipboard

Alpha applied at render time, independent of any alpha already baked into the source pixels.

Link copied to clipboard

Two-corner AABB in world space: [topLeft, bottomRight].

Link copied to clipboard
open override val rotation: Float

Rotation in degrees, applied around the element's axis-aligned bounding box center at render time. Points stored on the element are in the unrotated (logical) coordinate space.

Link copied to clipboard
open override val type: String

String identifier of the element type for serialization

Link copied to clipboard
open override val zIndex: Int

Layering order (higher values appear on top)

Functions

Link copied to clipboard

Axis-aligned bounding box of the element in unrotated logical space.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun Element.hitTest(point: Offset, tolerance: Float = 8.0f): Boolean

Hit test against a world-space point. Inverse-rotates the point into the element's logical space, then applies a per-type test that accounts for stroke width and the provided pick tolerance.

Link copied to clipboard
Link copied to clipboard
fun Element.touched(now: Long = kotlin.time.Clock.System.now().toEpochMilliseconds()): Element

Stamp Element.modifiedAt with now (defaults to current epoch ms). Call this on every mutation site so sync layers see a fresh LWW timestamp.

Link copied to clipboard

Translate all points by delta. Rotation unchanged.

Link copied to clipboard
fun Element.withBounds(newBounds: Rect): Element

Scale points so the bounding box matches newBounds. For two-point shapes this snaps start/end to the new bbox corners (preserving orientation of the original drag direction). For freedraw paths every point is scaled linearly. Rotation unchanged.

Link copied to clipboard

Absolute rotation in degrees.