mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Apply vgsl angle gradient
commit_hash:985ba800434a47d4b37eb50c6d8e9fbc293e964b
This commit is contained in:
@@ -14,7 +14,7 @@ extension Gradient.Linear {
|
||||
startColor: start.color,
|
||||
intermediatePoints: sortedPoints,
|
||||
endColor: end.color,
|
||||
direction: .init(angle: angle)
|
||||
direction: .angle(Double(angle))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,29 +29,11 @@ extension Gradient.Linear {
|
||||
startColor: start,
|
||||
intermediateColors: intermediateColors,
|
||||
endColor: end,
|
||||
direction: .init(angle: angle)
|
||||
direction: .angle(Double(angle))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Gradient.Linear.Direction {
|
||||
init(angle: Int) {
|
||||
let alpha = Double(angle) / 180.0 * .pi
|
||||
let toRaw = CGPoint(x: cos(alpha), y: sin(alpha))
|
||||
let scale = (abs(toRaw.x) + abs(toRaw.y)) / 2
|
||||
let toNormalized = toRaw * scale
|
||||
let to = RelativePoint(
|
||||
x: toNormalized.x + 0.5,
|
||||
y: 1 - (toNormalized.y + 0.5)
|
||||
) // 1 - a is to flip geometry
|
||||
let from = RelativePoint(
|
||||
x: -toNormalized.x + 0.5,
|
||||
y: 1 - (-toNormalized.y + 0.5)
|
||||
)
|
||||
self.init(from: from, to: to)
|
||||
}
|
||||
}
|
||||
|
||||
extension Gradient.Radial {
|
||||
init?(
|
||||
points: [Gradient.Point],
|
||||
|
||||
@@ -4,7 +4,7 @@ import Foundation
|
||||
import PackageDescription
|
||||
|
||||
let vgsl = {
|
||||
let version = Version("7.3.0")
|
||||
let version = Version("7.4.0")
|
||||
return (
|
||||
package: Package.Dependency.package(url: "https://github.com/yandex/vgsl.git", from: version),
|
||||
packageName: "vgsl"
|
||||
|
||||
Reference in New Issue
Block a user