PFColorHash 2.0.0

PFColorHash 2.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016 年 10 月
SPM支持 SPM

Cee Cirno 维护。



PFColorHash

Swift 3.0 支持!

根据给定的字符串生成颜色。感谢 color-hash

Sample

使用方法

基本

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'

自定义哈希函数 / 亮度 / 饱和度

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])

许可证

在使用 MIT 许可证下发布。