BlobLayer

data class BlobLayer(val color: Color = Color.White, val brush: Brush? = null, val alpha: Float = 1.0f, val segments: Int = 6, val amplitude: ClosedRange<Dp> = (-4).dp..4.dp, val tempo: Float = 1.0f, val rotation: Float = 0.0f, val spin: Float = 0.0f, val blur: Dp = 0.dp, val blendMode: BlendMode = BlendMode.SrcOver, val strokeWidth: Dp = 0.dp, val visible: Boolean = true, val seed: Int? = null)(source)

One morphing outline drawn by Blob.

The layer starts from the blob's shape and pushes every point of the outline along its normal. segments control points sit at equal distances around the outline. Each one moves on its own smooth, seeded curve inside amplitude, and the outline between two control points follows a smooth curve through them. A layer with an amplitude of 0.dp..0.dp is the plain shape, which is how you draw a solid, still body under or over the moving layers.

Constructors

Link copied to clipboard
constructor(color: Color = Color.White, brush: Brush? = null, alpha: Float = 1.0f, segments: Int = 6, amplitude: ClosedRange<Dp> = (-4).dp..4.dp, tempo: Float = 1.0f, rotation: Float = 0.0f, spin: Float = 0.0f, blur: Dp = 0.dp, blendMode: BlendMode = BlendMode.SrcOver, strokeWidth: Dp = 0.dp, visible: Boolean = true, seed: Int? = null)

Properties

Link copied to clipboard

Opacity multiplier in 0..1, applied on top of the color or brush.

Link copied to clipboard

How far the outline can move from the shape, along the outward normal. Negative values move inward. (-3).dp..5.dp lets the outline dip 3 dp in and bulge 5 dp out.

Link copied to clipboard

How the layer is composited with what is already drawn under it.

Link copied to clipboard
val blur: Dp

Blur radius. Needs Android 12 (API 31) or later; older Android draws the layer sharp. iOS always blurs.

Link copied to clipboard
val brush: Brush?

Optional brush, for example a gradient, used instead of color.

Link copied to clipboard

Fill color. Ignored when brush is set.

Link copied to clipboard

Starting angle of the wobble pattern in degrees. The pattern is shifted along the outline, so two layers with the same seed and a different rotation are offset from each other. On a circle this is the same as rotating the layer.

Link copied to clipboard
val seed: Int?

Seed of the control points' motion. Null derives a seed from the layer's position in the list, so layers move independently without any setup.

Link copied to clipboard

Number of control points around the outline. 4 gives a slow, calm wobble; 20 puts a new bump every 18° of a circle and makes the outline busy.

Link copied to clipboard
val spin: Float

Degrees per second the wobble pattern travels around the outline. Negative spins the other way.

Link copied to clipboard

0 fills the layer. Above 0 draws only its outline, this thick, centered on the moving outline.

Link copied to clipboard

Speed multiplier for the wobble. 1 is the default pace, 0 freezes the layer.

Link copied to clipboard

False skips drawing the layer. It keeps its place in the list and keeps moving while hidden, so showing it again does not make it or the other layers jump.