-
-
Save KatieBarnett/8852f0cc216af232d5491ca5d05e9abe to your computer and use it in GitHub Desktop.
Complex photo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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