objective c - getRandomColor but avoid dark colors: Help my algorithm -
I'm trying to get a random color. I use it is brute force, but this method seems much more strenuous (although delivery is pretty too):
- (UIColor *) getRandomColor {// Goals: reject color too Deep Boats are Total = 3; Float A = ArS 4 Random (%) 256 / 256.0; Total - = A; Float two = arc4random ()% 256 / 256.0; Total - = two; Float three = total; // UIColor will NSMutableArray out of range Cutting nums * threeFloats = [[[NSMutableArray alloc] initWithObjects: [NSNumber numberWithFloat: a], [NSNumber numberWithFloat: two], [NSNumber numberWithFloat: three], minus] autorelease]; Nsnm * red, * green, * blue; Red = [three flight objects atindex: ARC 4 RRM (%) [Count three floats]]; [Three floats removed objects: red]; Green = [three flight objects atindex: ARC 4 random ()% [three floats count]]; [Three flights removed objects: green]; Blue = [three flights final object]; Return [UIColor colorWithRed: [Red floatValue] beat [Green Float value] Blue: [Blue float value] alpha: 1]; }
How can it be improved? I blush, I want to make an even distribution of green and blue and a dark (otherwise I'd get three random numbers and go with it).
+ (UIColor *) colorWithHue: (CGFloat) Color saturation: (CGFloat) saturation shine : (CGFloat) Glow alpha: (CGFloat) Alpha; CGFloat hue = (arc4random (% 256 / 256.0); // 0.0 1.0 CGFloat saturation = (arc4random ()% 128 / 256.0) + 0.5; // 0.5 1.0 = off white CGFloat brightness (arc4random ()% 128 / 256.0) + 0.5;
Comments
Post a Comment