Is there any way to have a degree adjust for a lin...
# compose
c
Is there any way to have a degree adjust for a linearGradient?
Copy code
Brush.linearGradient(listOf()))
My designer keeps giving me stuff like this 😅
background: linear-gradient(180deg, rgba(5, 64, 87, 0.5)
and
background: linear-gradient(215.31deg, rgba(255, 255, 255, 0.1)
e
180° is just a vertical gradient in reverse, isn't it?
c
I guess 180 degree was a bad example, but in general, how would I go about setting values like 215 degrees
e
looks like Brush.linearGradient doesn't have a way to adjust the angle directly, but you can adjust the start and end offsets to match the angle with some math
too lazy to work through the trig but luckily somebody else has: https://stackoverflow.com/a/68223861
c
Oh cool. I didn't know if there was a way to do it out of the box that I was missing. I'll open a FR for this.
c
Thanks for creating that request. I believe we had a similar conversation on this months ago, but I think it wasn’t clear if we should change the API for
linearGradient
. From what I recall, you can achieve this but through doing some maths (I haven’t done it myself).
👍 1
c
Yeah, some of these gradient definitions from my design team are killing me. hahaha
Trying to draw a border with a linear gradient brush that has a degree set is mind blown
mind blown 2
c
That StackOverflow thread seems promising for creating a utility function in the meantime
c
Yeah. The stack overflow thread is ace for background, but now creating a border is another story. So far its a lot of copy pasta from the source. 🤞