Skip to content

Instantly share code, notes, and snippets.

@Composable
private fun Highlight(
modifier: Modifier
) {
Canvas(modifier) {
drawRect(
color = Color.Yellow,
size = size,
alpha = 0.15f
)
@Composable
private fun CircleDecoratedSquare(
modifier: Modifier
) {
Canvas(modifier) {
drawCircle(
color = Color.DarkGray,
radius = size.minDimension / 3f, // 6f for a smaller one
alpha = 0.25f,
style = Stroke(width = size.minDimension / 12f) // or Fill
@Composable
fun Moves(
gameState: GameState,
onClickMove: (Int) -> Unit,
) {
val listState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
LazyRow(
state = listState,
@Composable
private fun Pill(content: @Composable () -> Unit) {
Box(
modifier = Modifier
.background(
color = someColour,
shape = RoundedCornerShape(6.dp)
)
) {
content()
private fun Modifier.pill(): Modifier =
this.background(
color = someColour,
shape = RoundedCornerShape(6.dp)
)
BoxWithConstraints(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
) {
val squareSize = maxWidth / 8
}
val fromPosition = properties.fromState.board.find(piece)?.position
val currentOffset = fromPosition
?.toCoordinate(properties.isFlipped)
?.toOffset(properties.squareSize)
val targetOffset = toPosition
.toCoordinate(properties.isFlipped)
.toOffset(properties.squareSize)
val offset = remember { Animatable(currentOffset ?: targetOffset, Offset.VectorConverter) }
LaunchedEffect(targetOffset) {
offset.animateTo(targetOffset, tween(100, easing = LinearEasing))
}
Piece(
piece = piece,
modifier = offset.value.toModifier()
)
val offset = remember { Animatable(currentOffset ?: targetOffset, Offset.VectorConverter) }
LaunchedEffect(targetOffset) {
offset.animateTo(targetOffset, tween(100, easing = LinearEasing))
}
LaunchedEffect(isFlipped) {
offset.snapTo(targetOffset)
}
interface DatasetVisualisation : Parcelable {
// String resource
val name: Int
// Global minimum value
val minValue: Int
// Global maximum value
val maxValue: Int