BackgroundSchema

@Serializable
sealed interface BackgroundSchema

Fill applied to a tile by StyleSchema.background. Each variant maps 1:1 to a Compose Brush factory and is applied through Modifier.background(brush, alpha = alpha).

Variants:

null means "Compose default": since the tile size is unknown server-side, unspecified geometry is sent as null and resolved at draw time: | field | null resolves to | |---|---| | end (linear) | Offset.Infinite — bottom-end corner | | endX / endY | Float.POSITIVE_INFINITY — far edge | | center (radial/sweep) | Offset.Unspecified — center of the tile | | radius (radial) | Float.POSITIVE_INFINITY — largest radius that fits |

All dimensions are Int in dp, like every other dimension in Mosaic.

alpha is a 0f..1f multiplier applied to the whole fill, on top of any alpha already carried by the colors themselves.

DSL helpers (mosaic-server):

background(color(themeColorSurface()))                       // shorthand for SolidColor
background(solidColor(color(themeColorSurface()), alpha = 0.5f))
background(verticalGradient(0f to color(...), 1f to color(...)))
background(linearGradient(listOf(color(...), color(...)))) // evenly spread
background(radialGradient(listOf(color(...), color(...)), center = offset(40, 40), radius = 80))
background(sweepGradient(listOf(color(...), color(...), color(...))))

Note: blur is not supported yet.

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "horizontal_gradient")
data class HorizontalGradient(val colorStops: List<ColorStopSchema>, val startX: Int = 0, val endX: Int? = null, val tileMode: TileModeSchema = TileModeSchema.CLAMP, val alpha: Float = 1.0f) : BackgroundSchema
Link copied to clipboard
@Serializable
@SerialName(value = "linear_gradient")
data class LinearGradient(val colorStops: List<ColorStopSchema>, val start: OffsetSchema = OffsetSchema.Zero, val end: OffsetSchema? = null, val tileMode: TileModeSchema = TileModeSchema.CLAMP, val alpha: Float = 1.0f) : BackgroundSchema
Link copied to clipboard
@Serializable
@SerialName(value = "radial_gradient")
data class RadialGradient(val colorStops: List<ColorStopSchema>, val center: OffsetSchema? = null, val radius: Int? = null, val tileMode: TileModeSchema = TileModeSchema.CLAMP, val alpha: Float = 1.0f) : BackgroundSchema
Link copied to clipboard
@Serializable
@SerialName(value = "solid_color")
data class SolidColor(val color: ColorSchema, val alpha: Float = 1.0f) : BackgroundSchema
Link copied to clipboard
@Serializable
@SerialName(value = "sweep_gradient")
data class SweepGradient(val colorStops: List<ColorStopSchema>, val center: OffsetSchema? = null, val alpha: Float = 1.0f) : BackgroundSchema
Link copied to clipboard
@Serializable
@SerialName(value = "vertical_gradient")
data class VerticalGradient(val colorStops: List<ColorStopSchema>, val startY: Int = 0, val endY: Int? = null, val tileMode: TileModeSchema = TileModeSchema.CLAMP, val alpha: Float = 1.0f) : BackgroundSchema

Properties

Link copied to clipboard
abstract val alpha: Float