Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Created August 27, 2023 10:03
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 KatieBarnett/8852f0cc216af232d5491ca5d05e9abe to your computer and use it in GitHub Desktop.
Save KatieBarnett/8852f0cc216af232d5491ca5d05e9abe to your computer and use it in GitHub Desktop.
Complex photo
@Composable
fun PhotoScene(modifier: Modifier = Modifier, showGrey: Boolean) {
val backgroundColor = if (showGrey) {
Color.LightGray
} else {
Sunlight
}
val textColor = if (showGrey) {
Color.Gray
} else {
Pink
}
val photoColorFilter = if (showGrey) {
ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(0f) })
} else {
null
}
Column(modifier.background(backgroundColor)) {
Image(
painter = painterResource(drawable.rose),
contentDescription = "Scene",
colorFilter = photoColorFilter,
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
)
val hexColor = String.format("#%06X", 0xFFFFFF and Pink.toArgb())
Text(text = "This is $hexColor text and a photo\n", color = textColor, textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth().padding(4.dp))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment