Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdds-acore/theme-builder): compose gradients were fixed #283

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading