Demo entry 3300743

Colour Wheel

   

Submitted by Matt on Dec 12, 2015 at 13:50
Language: Swift. Code size: 2.7 kB.

//
//  ColourWheel.swift
//  FunFacts
//
//  Created by Matthew Spear on 26/01/2015.
//  Copyright (c) 2015 Matthew Spear. All rights reserved.
//

import Foundation
import UIKit

struct ColorWheel {
    
    var colorsArray = [
        UIColor(red: 90/255.0, green: 187/255.0, blue: 181/255.0, alpha: 1.0), //teal color
        UIColor(red: 222/255.0, green: 171/255.0, blue: 66/255.0, alpha: 1.0), //yellow color
        UIColor(red: 223/255.0, green: 86/255.0, blue: 94/255.0, alpha: 1.0), //red color
        UIColor(red: 239/255.0, green: 130/255.0, blue: 100/255.0, alpha: 1.0), //orange color
        UIColor(red: 77/255.0, green: 75/255.0, blue: 82/255.0, alpha: 1.0), //dark color
        UIColor(red: 105/255.0, green: 94/255.0, blue: 133/255.0, alpha: 1.0), //purple color
        UIColor(red: 85/255.0, green: 176/255.0, blue: 112/255.0, alpha: 1.0), //green color
    ]
    
//     var colorsArray = [
//        UIColor(red:0.102, green:0.737, blue:0.612, alpha:1.0), // green
//        UIColor(red:0.086, green:0.627, blue:0.522, alpha:1.0),
//        UIColor(red:0.180, green:0.800, blue:0.443, alpha:1.0),
//        UIColor(red:0.153, green:0.682, blue:0.376, alpha:1.0),
//        UIColor(red:0.204, green:0.596, blue:0.859, alpha:1.0), // blue
//        UIColor(red:0.161, green:0.502, blue:0.725, alpha:1.0),
//        UIColor(red:0.600, green:0.345, blue:0.706, alpha:1.0), // purple
//        UIColor(red:0.557, green:0.267, blue:0.678, alpha:1.0),
//        UIColor(red:0.945, green:0.769, blue:0.059, alpha:1.0), // yellow
//        UIColor(red:0.953, green:0.612, blue:0.071, alpha:1.0), // orange
//        UIColor(red:0.902, green:0.494, blue:0.133, alpha:1.0),
//        UIColor(red:0.827, green:0.329, blue:0.000, alpha:1.0),
//        UIColor(red:0.906, green:0.298, blue:0.235, alpha:1.0), // red
//        UIColor(red:0.753, green:0.224, blue:0.169, alpha:1.0)]
    
//    var colorsArray = [
//        UIColor(red:0.902, green:0.137, blue:0.157, alpha:1.0),
//        UIColor(red:0.969, green:0.584, blue:0.133, alpha:1.0),
//        UIColor(red:0.973, green:0.937, blue:0.141, alpha:1.0),
//        UIColor(red:0.553, green:0.776, blue:0.259, alpha:1.0),
//        UIColor(red:0.314, green:0.784, blue:0.937, alpha:1.0),
//        UIColor(red:0.302, green:0.408, blue:1.000, alpha:1.0),
//        UIColor(red:0.408, green:0.341, blue:0.647, alpha:1.0)]

    
    func randomColor() -> UIColor {
        
        let unsignedArrayCount = UInt32(colorsArray.count)
        
        let unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
        
        let randomNumber = Int(unsignedRandomNumber)
        
        return colorsArray[randomNumber]
        
    }
    
    
    
    
    
    
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).