Maybe the inverse of <#C04TPPEQKEJ|compose-android...
# compose-android
c
Maybe the inverse of #compose-android, but I'm trying to move this file to compose multiplatform. The issue is with
import android.graphics.Matrix
https://gist.github.com/KlassenKonstantin/d5f6ed1d74b3ddbdca699d66c6b9a3b2 Is there a compose version of Matrix that has
postRotate
?
r
So you want a multiplatform matrix?
c
I suppose so? I'm basically just using that gist that someone has for creating a cool but fake fluid-eque background. thought itd be simple enough to put that into multiplatform, but i guess not.I do see import androidx.compose.ui.graphics.Matrix, but it doesn't seem to have postRotate available. so idk if its just something completely different.
r
All the rotate functions are post-rotate functions on that class
but if you want something more general, you can use this library I wrote (and it’s KMP ready): https://github.com/romainguy/kotlin-math
pre/post rotate is just a matter of the order of the operations
rotate(…) * matrix vs matrix * rotate(…)
c
cool. alright. i have no idea what im doing. but i converted val matrix = Matrix().apply { postRotate(angle, size.width / 2, size.height / 2) } to val matrix = Matrix().apply { rotateX(angle) }
i also cant seem to call shader.setLocalMatrix. 🤔
r
That's an Android specific API
c
gotcha. i guess i dont need a multiplatform gradient animation that bad. ill just use a static gradient. lol
r
but you can do it with regular Compose APIs
you could rotate the rectangles for instance
@Nader Jawad, we don’t have another way to apply a transform to a shader brush right?
n
setLocalMatrix is not yet exposed on the ShaderBrush API but you can use the Android shader APIs and create a ShaderBrush from that
I think you would want rotateZ to rotate content within the same plane
c
but if i wanted to do it in a multiplatform way... then theres no way to do that currently?
r
Right so that’s where instead you can rotate your
drawRect()
c
interesting. ill timebox this for a few more minutes and see if i can get something. thanks for the inspiration