The Goal
Function
func saturation(color,satval){
var inputColor:Color = color
var inputSat:float = Float(satval)
var outputColor:Color = Color.hsba(inputColor.hue / 360, inputSat / 100, inputColor.brightness, inputColor.alpha)
return outputColor
}
Takes two parameters:
- color: Color
- satval: Int
satval, represents a percentage of saturation required, value between 0 and 100
Example usage's
self.bacgroundColor = saturation(self.backgroundColor,30)
var value:Int = 100
for(var x in self.subviews){
x.backgroundColor = saturation(self.backgroundColor,value)
value = value - 10
}
// assuming 10 subviews to create a gradient effect accross the views
Why
Creting a HSB based Color requires input values of 0 -1 for all 4 parameters, hue, sat, brightness, and alpa.
Reading a Color.hue: Returns a value between 0 - 360
Reading the reamaining 3 paramaters of a Color returns a value of 0 - 1

