-
-
Save itsSiddharthGupta/865e54d95260138019df1e9346942a9a to your computer and use it in GitHub Desktop.
Circle Modifier Node
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
// Modifier factory | |
fun Modifier.circle(color: Color) = this then CircleElement(color) | |
// ModifierNodeElement | |
private data class CircleElement(val color: Color) : ModifierNodeElement<CircleNode>() { | |
override fun create() = CircleNode(color) | |
override fun update(node: CircleNode) { | |
node.color = color | |
} | |
} | |
// Modifier.Node | |
private class CircleNode(var color: Color) : DrawModifierNode, Modifier.Node() { | |
override fun ContentDrawScope.draw() { | |
drawCircle(color) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment