https://kotlinlang.org logo
#compose
Title
# compose
t

Tash

06/10/2022, 6:15 PM
Looking for a good way to draw a 45deg linear gradient. Came across this SO, but wondering if there’s a more up-to-date alternative 🤔
c

Colton Idle

06/10/2022, 7:31 PM
I filed a bug for this!
But besides that SO post, I haven't found anything else either
🙏 1
a

andrew

06/10/2022, 7:54 PM
You can also use matrices to rotate your gradient
Copy code
val shader = SweepGradientShader(
                Offset(width / 2, width / 2),
                colors,
                List(colors.size) {
                    _sweepDeg * (it.toFloat() / (colors.size - 1)) / 360F
                }
            ).apply {
                val matrix = Matrix()
                matrix.postRotate(_startDeg - capDeg, width / 2, width / 2)
                setLocalMatrix(matrix)
            }
Replace it with linear gradient
c

Colton Idle

06/11/2022, 12:11 AM
Here was my ticket in case anyone wants to +1 https://issuetracker.google.com/issues/204897507
t

Tash

06/12/2022, 9:41 PM
Oh that's an interesting idea @andrew, thanks! Thanks for creating the issue @Colton Idle went ahead and 'd it
2 Views