Skip to content

Instantly share code, notes, and snippets.

@mahendranv
Created July 9, 2021 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahendranv/794e9584cc003c83f1790c8badac262f to your computer and use it in GitHub Desktop.
Save mahendranv/794e9584cc003c83f1790c8badac262f to your computer and use it in GitHub Desktop.
val HeartShape = GenericShape { size, _ ->
val h = size.height
val w = size.width
lineTo(0.5f*w, 0.25f*h)
cubicTo(0.5f*w, 0.225f*h, 0.458333333333333f*w, 0.125f*h, 0.291666666666667f*w, 0.125f*h)
cubicTo(0.0416666666666667f*w, 0.125f*h, 0.0416666666666667f*w, 0.4f*h, 0.0416666666666667f*w, 0.4f*h)
cubicTo(0.0416666666666667f*w, 0.583333333333333f*h, 0.208333333333333f*w, 0.766666666666667f*h, 0.5f*w, 0.916666666666667f*h)
cubicTo(0.791666666666667f*w, 0.766666666666667f*h, 0.958333333333333f*w, 0.583333333333333f*h, 0.958333333333333f*w, 0.4f*h)
cubicTo(0.958333333333333f*w, 0.4f*h, 0.958333333333333f*w, 0.125f*h, 0.708333333333333f*w, 0.125f*h)
cubicTo(0.583333333333333f*w, 0.125f*h, 0.5f*w, 0.225f*h, 0.5f*w, 0.25f*h)
close()
}
@Composable
fun Heart(modifier: Modifier = Modifier) {
Surface(
shape = HeartShape,
color = color_orange,
modifier = Modifier
.height(100.dp)
.width(100.dp)
) {
// An image view?
}
}
@mahendranv
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment