Path

data class Path(val id: String = Uuid.random().toString(), val type: String = "Path", val samples: List<Element.PathSample>, val strokeColor: Color, val strokeWidth: Float, val alpha: Float, val zIndex: Int = 0, val rotation: Float = 0.0f, val strokeStyle: StrokeStyle = StrokeStyle.SOLID, val createdAt: Long = 0, val modifiedAt: Long = 0) : Element

Constructors

Link copied to clipboard
constructor(id: String = Uuid.random().toString(), type: String = "Path", samples: List<Element.PathSample>, strokeColor: Color, strokeWidth: Float, alpha: Float, zIndex: Int = 0, rotation: Float = 0.0f, strokeStyle: StrokeStyle = StrokeStyle.SOLID, createdAt: Long = 0, modifiedAt: Long = 0)

Properties

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

The spatial positions of every sample in a freehand stroke, in order. Use this when the caller only cares about geometry (bounds, hit testing, path tessellation); reach for Element.Path.samples directly when widths are also needed.

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

Ordered samples along the stroke. Each sample carries both its world-space position and its width, so pressure-modulated strokes are represented natively without a parallel widths list. Uniform strokes simply set every sample's width to strokeWidth.

Link copied to clipboard
Link copied to clipboard

Stroke pattern for the freehand path. SOLID keeps the natural pencil feel.

Link copied to clipboard

Default width applied to new samples appended during the active stroke. Existing samples carry their own width; setters that mutate width across the whole stroke (SetSelectedStrokeWidth) overwrite every sample's width to keep the stroke uniform.

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