Glass updates

This commit is contained in:
Isaac 2026-01-11 21:01:45 +04:00
parent 1425fd8973
commit 0f5a019f04
23 changed files with 1000 additions and 592 deletions

View file

@ -396,7 +396,7 @@ public enum GradientImageDirection {
case mirroredDiagonal
}
public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [UIColor], locations: [CGFloat], direction: GradientImageDirection = .vertical) -> UIImage? {
public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [UIColor], locations: [CGFloat], direction: GradientImageDirection = .vertical, isInverted: Bool = false) -> UIImage? {
guard colors.count == locations.count else {
return nil
}
@ -408,7 +408,11 @@ public func generateGradientImage(size: CGSize, scale: CGFloat = 0.0, colors: [U
var locations = locations
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
if isInverted {
context.drawLinearGradient(gradient, start: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), end: CGPoint(x: 0.0, y: 0.0), options: CGGradientDrawingOptions())
} else {
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: direction == .horizontal ? CGPoint(x: size.width, y: 0.0) : CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
}
}
let image = UIGraphicsGetImageFromCurrentImageContext()!

View file

@ -116,3 +116,9 @@ open class SimpleTransformLayer: CATransformLayer {
fatalError("init(coder:) has not been implemented")
}
}
public final class SimpleLayerDelegate: NSObject, CALayerDelegate {
public func action(for layer: CALayer, forKey event: String) -> CAAction? {
return nullAction
}
}

View file

@ -881,6 +881,10 @@ public extension CALayer {
return makeBlurFilter()
}
static func variableBlur() -> NSObject? {
return makeVariableBlurFilter()
}
static func luminanceToAlpha() -> NSObject? {
return makeLuminanceToAlphaFilter()
}