Stylianos Gakis
11/08/2024, 1:06 PMBrush.horizontalGradient(
0.9f to Color.Black,
1f to Color.Transparent,
)
But I also wanted to if possible be able to pass an Easing
regarding how that section between 0.9f and 1.0f will progress.
Right now it does a linear change from Black to Transparent, but is there a way for me to give it just an Easing
in there, or would I need to "hack" it by doing something like
Brush.horizontalGradient(
0.9f to Color.Black,
0.92f to figureThisOutMyself(),
0.94f to figureThisOutMyself(),
0.96f to figureThisOutMyself(),
0.98f to figureThisOutMyself(),
1f to Color.Transparent,
)
And just play with it until it stops feeling choppy?
The use case is to do something like this but the way that the fade happens linearly looks not so nice in some scenarios.Stylianos Gakis
11/08/2024, 1:08 PMStylianos Gakis
11/08/2024, 1:09 PMinternal fun HazeProgressive.LinearGradient.asBrush(numStops: Int = 20): Brush {
return Brush.linearGradient(
colors = List(numStops) { i ->
val x = i * 1f / (numStops - 1)
Color.Black.copy(alpha = lerp(startIntensity, endIntensity, easing.transform(x)))
},
start = start,
end = end,
)
}
Perhaps that is the way indeed, make enough stops where this feels good enough, but in reality you are still using normal linear scaling in-between these stopsyschimke
11/08/2024, 1:22 PMyschimke
11/08/2024, 1:24 PMpublic class LinearGradient extends Shader {
private float mX0;
private float mY0;
private float mX1;
private float mY1;
private float[] mPositions;
private TileMode mTileMode;
...
@ColorLong
private final long[] mColorLongs;
Stylianos Gakis
11/08/2024, 2:00 PMyschimke
11/08/2024, 3:05 PMromainguy
11/08/2024, 3:40 PMromainguy
11/08/2024, 3:40 PMromainguy
11/08/2024, 4:17 PMStylianos Gakis
11/08/2024, 4:22 PMromainguy
11/08/2024, 4:35 PMromainguy
11/08/2024, 4:49 PMthePath.asAndroidPath().approximate()
(https://developer.android.com/reference/android/graphics/Path.html#approximate(float))romainguy
11/08/2024, 4:50 PMromainguy
11/08/2024, 5:00 PMromainguy
11/08/2024, 5:01 PMStylianos Gakis
11/08/2024, 6:23 PMromainguy
11/08/2024, 6:36 PMromainguy
11/08/2024, 6:40 PM