Looking for a good way to draw a 45deg linear grad...
# compose
t
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
I filed a bug for this!
But besides that SO post, I haven't found anything else either
🙏 1
a
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
Here was my ticket in case anyone wants to +1 https://issuetracker.google.com/issues/204897507
t
Oh that's an interesting idea @andrew, thanks! Thanks for creating the issue @Colton Idle went ahead and 'd it