Stylianos Gakis
11/10/2024, 12:12 AMdrawWithContent
. Am I typically not allowed to draw outside of my canvas' bounds perhaps?
More details in thread 🧵Stylianos Gakis
11/10/2024, 12:12 AM.drawWithContent {
drawContent()
drawRect(
brush = Brush.horizontalGradient(
colors = listOf(someColor, someOtherColor),
startX = size.width,
endX = size.width + 4.dp.toPx(), // I tried just `4.dp.toPx(),` too but that's not it either.
),
)
}
It seems to sort of "overflow" and just draws the first color over the entire item instead, never painting with any of the someOtherColor
.Stylianos Gakis
11/10/2024, 12:14 AMtopLeft
parameter on the drawRect
function fixes this.
So do instead
drawRect(
topLeft = Offset(size.width, 0f),
size = Size(4.dp.toPx(), size.height),
brush = SolidColor(Color.Red),
)
romainguy
11/10/2024, 12:15 AMromainguy
11/10/2024, 12:15 AMStylianos Gakis
11/10/2024, 12:45 AMval mySizeInPx = ...
val myColor = ...
drawRect(
topLeft = Offset(size.width, 0f),
size = Size(mySizeInPx, size.height),
brush = Brush.horizontalGradient(
colors = listOf(myColor, Color.Transparent),
startX = size.width,
endX = size.width + mySizeInPx,
),
)
Stylianos Gakis
11/10/2024, 1:01 AMsize
due to those.
Since I was passing nothing to topLeft
and to size
And then on my brush I was giving it an endX which was outside of those bounds. No wonder it was acting not even close to what I wanted it to do 😅