我在我的应用程序中有这样一个循环:
for var hue = minHue; hue <= maxHue; hue += hueIncrement
{
let randomizedHue = UIColor.clipHue(
Random.uniform(ClosedInterval(hue - dispersion, hue + dispersion))
)
colors.append(colorWithHue(randomizedHue))
}
hueIncrement
是 浮点数,所以我不能像这样使用范围运算符:..<
。
在 Swift 3 中,最好、最简洁的实现循环的方法是什么?
hue
,从最小色调minHue
开始,以hueIncrement
为步长逐渐增加到最大色调maxHue
。 - Bhavin Bhadani