Latest 2.0.0
Homepage https://github.com/PerfectFreeze/PFColorHash
License MIT
Platforms ios 8.0, requires ARC
Authors

Cocoapods

Swift 3.0 SUPPORT!

Generate color based on the given string. Thanks to color-hash.

Sample

Usage

Basic

let colorHash = PFColorHash()

// in HSL, Hue ∈ [0, 360), Saturation ∈ [0, 1], Lightness ∈ [0, 1]
colorHash.hsl('Hello World') // [ 225, 0.65, 0.35 ]

// in RGB, R, G, B ∈ [0, 255]
colorHash.rgb('Hello World') // [ 134, 150, 196 ]

// in HEX
colorHash.hex('Hello World') // '#8696c4'

Custom Hash Function / Lightness / Saturation

let colorHash = PFColorHash(hash: { (str: String) -> Int64 in
    var hashValue: Int64 = 0
    // Your Hash Function Here
    return hashValue
})
let colorHash = PFColorHash(lightness: [0.35, 0.5, 0.65])
let colorHash = PFColorHash(saturation: [0.35, 0.5, 0.65])
let colorHash = PFColorHash(lightness: [0.35, 0.5, 0.65], saturation: [0.35, 0.5, 0.65])

License

Released under the MIT License.

Latest podspec

{
    "name": "PFColorHash",
    "version": "2.0.0",
    "summary": "Generate color based on the given string.",
    "homepage": "https://github.com/PerfectFreeze/PFColorHash",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Cee": "[email protected]"
    },
    "social_media_url": "https://twitter.com/Ceecirno",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/PerfectFreeze/PFColorHash.git",
        "tag": "v2.0.0"
    },
    "source_files": "Class/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This