Skip to content

Commit

Permalink
fix(sdds-acore/theme-builder): compose gradients were fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
raininforest committed Feb 21, 2025
1 parent 186f153 commit 667e66f
Show file tree
Hide file tree
Showing 30 changed files with 10 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ internal class ComposeGradientAttributeGenerator(
),
),
body = listOf(
"return $LINEAR_GRADIENT_CLASS_NAME(colors, positions.toList(), " +
"angleInDegrees = angle, useAsCssAngle = true)",
"return $LINEAR_GRADIENT_CLASS_NAME(colors, positions.toList(), angle)",
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ import kotlin.math.sqrt
* @param stops точки остановки цвета
* @param tileMode определяет поведение на границах градиента
* @param angleInDegrees угол в градусах
* @param useAsCssAngle меняет режим отрисовки на
*/
@Immutable
internal class ThmbldrLinearGradient constructor(
private val colors: List<Color>,
private val stops: List<Float>? = null,
angleInDegrees: Float = 0f,
useAsCssAngle: Boolean = false,
private val tileMode: TileMode = TileMode.Clamp,
) : ShaderBrush() {

private val normalizedAngle: Float = if (useAsCssAngle) {
((90 - angleInDegrees) % 360 + 360) % 360
} else {
(angleInDegrees % 360 + 360) % 360
}
private val normalizedAngle: Float = (angleInDegrees % 360 + 360) % 360
private val angleInRadians: Float = Math.toRadians(normalizedAngle.toDouble()).toFloat()

override fun createShader(size: Size): Shader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@ import kotlin.math.sqrt
* @param stops точки остановки цвета
* @param tileMode определяет поведение на границах градиента
* @param angleInDegrees угол в градусах
* @param useAsCssAngle меняет режим отрисовки на
*/
@Immutable
internal class ThmbldrLinearGradient constructor(
private val colors: List<Color>,
private val stops: List<Float>? = null,
angleInDegrees: Float = 0f,
useAsCssAngle: Boolean = false,
private val tileMode: TileMode = TileMode.Clamp,
) : ShaderBrush() {

private val normalizedAngle: Float = if (useAsCssAngle) {
((90 - angleInDegrees) % 360 + 360) % 360
} else {
(angleInDegrees % 360 + 360) % 360
}
private val normalizedAngle: Float = (angleInDegrees % 360 + 360) % 360
private val angleInRadians: Float = Math.toRadians(normalizedAngle.toDouble()).toFloat()

override fun createShader(size: Size): Shader {
Expand Down Expand Up @@ -315,8 +309,7 @@ internal fun linearGradient(
colors: List<Color>,
positions: FloatArray,
angle: Float,
): ShaderBrush = ThmbldrLinearGradient(colors, positions.toList(), angleInDegrees = angle,
useAsCssAngle = true)
): ShaderBrush = ThmbldrLinearGradient(colors, positions.toList(), angle)

internal fun radialGradient(
colors: List<Color>,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1649,12 +1649,7 @@ internal fun linearGradient(
colors: List<Color>,
positions: FloatArray,
angle: Float,
): ShaderBrush = ThmbldrLinearGradient(
colors,
positions.toList(),
angleInDegrees = angle,
useAsCssAngle = true,
)
): ShaderBrush = ThmbldrLinearGradient(colors, positions.toList(), angle)

internal fun radialGradient(
colors: List<Color>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@ import kotlin.math.sqrt
* @param stops точки остановки цвета
* @param tileMode определяет поведение на границах градиента
* @param angleInDegrees угол в градусах
* @param useAsCssAngle меняет режим отрисовки на
*/
@Immutable
internal class ThmbldrLinearGradient constructor(
private val colors: List<Color>,
private val stops: List<Float>? = null,
angleInDegrees: Float = 0f,
useAsCssAngle: Boolean = false,
private val tileMode: TileMode = TileMode.Clamp,
) : ShaderBrush() {

private val normalizedAngle: Float = if (useAsCssAngle) {
((90 - angleInDegrees) % 360 + 360) % 360
} else {
(angleInDegrees % 360 + 360) % 360
}
private val normalizedAngle: Float = (angleInDegrees % 360 + 360) % 360
private val angleInRadians: Float = Math.toRadians(normalizedAngle.toDouble()).toFloat()

override fun createShader(size: Size): Shader {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6699,12 +6699,7 @@ internal fun linearGradient(
colors: List<Color>,
positions: FloatArray,
angle: Float,
): ShaderBrush = ThmbldrLinearGradient(
colors,
positions.toList(),
angleInDegrees = angle,
useAsCssAngle = true,
)
): ShaderBrush = ThmbldrLinearGradient(colors, positions.toList(), angle)

internal fun radialGradient(
colors: List<Color>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@ import kotlin.math.sqrt
* @param stops точки остановки цвета
* @param tileMode определяет поведение на границах градиента
* @param angleInDegrees угол в градусах
* @param useAsCssAngle меняет режим отрисовки на
*/
@Immutable
internal class ThmbldrLinearGradient constructor(
private val colors: List<Color>,
private val stops: List<Float>? = null,
angleInDegrees: Float = 0f,
useAsCssAngle: Boolean = false,
private val tileMode: TileMode = TileMode.Clamp,
) : ShaderBrush() {

private val normalizedAngle: Float = if (useAsCssAngle) {
((90 - angleInDegrees) % 360 + 360) % 360
} else {
(angleInDegrees % 360 + 360) % 360
}
private val normalizedAngle: Float = (angleInDegrees % 360 + 360) % 360
private val angleInRadians: Float = Math.toRadians(normalizedAngle.toDouble()).toFloat()

override fun createShader(size: Size): Shader {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9411,12 +9411,7 @@ internal fun linearGradient(
colors: List<Color>,
positions: FloatArray,
angle: Float,
): ShaderBrush = ThmbldrLinearGradient(
colors,
positions.toList(),
angleInDegrees = angle,
useAsCssAngle = true,
)
): ShaderBrush = ThmbldrLinearGradient(colors, positions.toList(), angle)

internal fun radialGradient(
colors: List<Color>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@ import kotlin.math.sqrt
* @param stops точки остановки цвета
* @param tileMode определяет поведение на границах градиента
* @param angleInDegrees угол в градусах
* @param useAsCssAngle меняет режим отрисовки на
*/
@Immutable
internal class ThmbldrLinearGradient constructor(
private val colors: List<Color>,
private val stops: List<Float>? = null,
angleInDegrees: Float = 0f,
useAsCssAngle: Boolean = false,
private val tileMode: TileMode = TileMode.Clamp,
) : ShaderBrush() {

private val normalizedAngle: Float = if (useAsCssAngle) {
((90 - angleInDegrees) % 360 + 360) % 360
} else {
(angleInDegrees % 360 + 360) % 360
}
private val normalizedAngle: Float = (angleInDegrees % 360 + 360) % 360
private val angleInRadians: Float = Math.toRadians(normalizedAngle.toDouble()).toFloat()

override fun createShader(size: Size): Shader {
Expand Down

0 comments on commit 667e66f

Please sign in to comment.