Files
babaevmm 5ea5e7ff05 support text range mask
commit_hash:1d250d40d05dc6aeff067c1e03aff9dc9b37bab2
2025-08-25 14:39:25 +03:00

55 lines
1.1 KiB
Swift

import CoreGraphics
import Foundation
public struct TextMask {
public enum MaskType: Equatable {
case solid
case particles(CGFloat, CGFloat)
}
public let type: MaskType
public let color: CGColor
public let range: CFRange
public let isAnimated: Bool
public let isEnabled: Bool
public init(
color: CGColor,
range: CFRange,
isEnabled: Bool
) {
self.type = .solid
self.color = color
self.range = range
self.isEnabled = isEnabled
self.isAnimated = false
}
public init(
color: CGColor,
range: CFRange,
isAnimated: Bool,
particleSize: CGFloat,
density: CGFloat,
isEnabled: Bool
) {
self.type = .particles(particleSize, density)
self.color = color
self.range = range
self.isAnimated = isAnimated
self.isEnabled = isEnabled
}
}
extension TextMask: Equatable {
public static func ==(lhs: TextMask, rhs: TextMask) -> Bool {
lhs.type == rhs.type
&& lhs.color == rhs.color
&& lhs.range.length == rhs.range.length
&& lhs.range.location == rhs.range.location
&& lhs.isAnimated == rhs.isAnimated
&& lhs.isEnabled == rhs.isEnabled
}
}