平滑渐变 (SmoothGradient) 帮助您生成美观且极其平滑的渐变。它通过在 RGB 以外的色彩空间中插值颜色,帮助您避免渐变中间出现灰色死区。
这个包的灵感主要来源于这个 渐变生成器。您可以点击链接了解其工作原理。
let colors: [UIColor] = SmoothGradientGenerator()
.generate(
from: fromColor,
to: toColor,
interpolation: .hcl, // choose from hcl, hsl, hsb
precision: .high
)
请查看示例 playground 以了解更多详情。
只需在 Xcode 或 Package.swift 中添加 https://github.com/intitni/SmoothGradient
作为依赖项即可。
MIT。