PeachMark.kt

2.5 KB · raw

1package com.peachpasswords.ui.components23import androidx.compose.foundation.Canvas4import androidx.compose.foundation.layout.size5import androidx.compose.runtime.Composable6import androidx.compose.runtime.remember7import androidx.compose.ui.Modifier8import androidx.compose.ui.geometry.Offset9import androidx.compose.ui.geometry.Size10import androidx.compose.ui.graphics.Color11import androidx.compose.ui.graphics.drawscope.Stroke12import androidx.compose.ui.graphics.drawscope.rotate13import androidx.compose.ui.graphics.drawscope.scale14import androidx.compose.ui.graphics.vector.PathParser15import androidx.compose.ui.unit.Dp16import androidx.compose.ui.unit.dp1718/**19 * The Peach brand mark — a peach fruit with a single leaf. Exact port of the20 * browser PeachMark.tsx SVG (viewBox 240×240). The leaf is ALWAYS sage green21 * (#92AC65 fill, #5E7A42 vein) and the body is fixed peach tones — none of it22 * is accent-driven. [alpha] dims the whole mark for the faint lock-screen art.23 */24@Composable25fun PeachMark(26    modifier: Modifier = Modifier,27    size: Dp = 14.dp,28    alpha: Float = 1f,29) {30    val leaf = remember {  PathParser().parsePathString("M 124 64 C 134 32 168 16 200 22 C 198 56 168 72 130 66 Z").toPath() }31    val vein = remember {  PathParser().parsePathString("M 130 64 C 152 46 178 30 196 24").toPath() }32    val bodyLight = remember {  PathParser().parsePathString("M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 185 222 222 185 220 130 C 218 78 170 45 120 60 Z").toPath() }33    val bodyShadow = remember {  PathParser().parsePathString("M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 105 195 75 150 100 90 C 105 75 112 65 120 60 Z").toPath() }3435    Canvas(modifier = modifier.size(size)) {36        val s = this.size.minDimension / 240f37        scale(scaleX = s, scaleY = s, pivot = Offset.Zero) {38            drawPath(bodyLight, Color(0xFFFFB082), alpha = alpha)39            drawPath(bodyShadow, Color(0xFFE5805C), alpha = alpha)40            // Highlight ellipse: cx178 cy108 rx20 ry11, rotate(-26°).41            rotate(degrees = -26f, pivot = Offset(178f, 108f)) {42                drawOval(43                    color = Color(0xFFFFD0A8),44                    topLeft = Offset(178f - 20f, 108f - 11f),45                    size = Size(40f, 22f),46                    alpha = alpha * 0.7f,47                )48            }49            drawPath(leaf, Color(0xFF92AC65), alpha = alpha)50            drawPath(vein, Color(0xFF5E7A42), alpha = alpha, style = Stroke(width = 2.6f))51        }52    }53}