Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

AbsoluteHSB

Swift 4.2

Overview

CLI to change all Swift UIColor initializer to HSB initializer

Requirements

Swift 4.2+ Xcode 10+

Installation

Run make command.

$ make install

Usage

When you write Swift code like below:

import UIKit

let color1 = UIColor(red: 0.2, green: 0.4, blue: 1.0, alpha: 1.0)
let color2 = UIColor.init(red: 0.5, green: 0.4, blue: 0.3, alpha: 0.4)
let color3 = UIColor(displayP3Red: 0.2, green: 0.4, blue: 1.0, alpha: 1.0)
let color4 = UIColor(white: 0.4, alpha: 0.8)

Then you run this command, you can get like this:

import UIKit

let color1 = UIColor(hue: 0.625, saturation: 0.8, brightness: 1.0, alpha: 1.0)
let color2 = UIColor.init(hue: 0.08333333333333333, saturation: 0.4, brightness: 0.5, alpha: 0.4)
let color3 = UIColor(hue: 0.610491388406303, saturation: 0.8959992453455925, brightness: 1.0, alpha: 1.0)
let color4 = UIColor(hue: 0.0, saturation: 0.0, brightness: 0.4, alpha: 0.8)

Of course, the output of these code is same. (note: Color value with display P3 color space will sometimes change because of changing color space, but it is indistinguishable with the naked eye.)

evidence

Available Command

dump

This command output converted code to standard ouput.

$ absolute-hsb dump <file-path>

rewrite

This command replace original code with converted code.

$ absolute-hsb rewrite <file-path>

help

This command show the help.

$ absolute-hsb help

Author

License

MIT License.

Special Thanks

This library based on this entry and library. And I started to develop this library in "Open Source Swift workshop in try! Swift 2019".

About

CLI to change all Swift UIColor initializer to HSB initializer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published