Skip to content

Instantly share code, notes, and snippets.

@cp-radhika-s
Created November 8, 2022 09:12
Show Gist options
  • Save cp-radhika-s/4d370cd6958e9f990995929f17305d57 to your computer and use it in GitHub Desktop.
Save cp-radhika-s/4d370cd6958e9f990995929f17305d57 to your computer and use it in GitHub Desktop.
@Composable
fun ExampleTextString() {
val textMeasure = rememberTextMeasurer()
Canvas(modifier = Modifier
.fillMaxWidth()
.height(100.dp), onDraw = {
drawRect(color = Color.Black)
drawText(
textMeasurer = textMeasure, text = "Text on Canvas!",
style = TextStyle(
fontSize = 35.sp,
brush = Brush.linearGradient(
colors = RainbowColors
)
),
topLeft = Offset(20.dp.toPx(), 20.dp.toPx())
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment