Qix- / color-convert

Plain color conversion functions in JavaScript
MIT License
746 stars 96 forks source link

UIColor #26

Closed kevinSuttle closed 8 years ago

kevinSuttle commented 8 years ago

Lots of Swift color formats, but SwiftUIRGB seems to be the most prominent I believe. Is there a more common equivalent or could color-convert output this format as well?

Qix- commented 8 years ago

Hi! Do you have a link to the SwiftUIRGB format?

kevinSuttle commented 8 years ago

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class https://www.ralfebert.de/snippets/ios/swift-uicolor-picker/

Sure, here's an example comparing hex. I've seen UIColor and SwiftUIColorRGB used interchangeably.

I have seen it as both in Sip for Mac.

hex: '#ffd2dd',
SwiftUIColorRGB: 'UIColor(red:1, green:0.823, blue:0.866, alpha:1)'
Qix- commented 8 years ago

All that format is is just the RGB values/255.

red:   0xFF/0xFF = 1
green: 0xD2/0xFF = 0.823
blue:  0xDD/0xFF = 0.866

Could just do

colorConver['something']['rgb'](...).map(function (c) { return c / 255; });

Not sure if this is specific enough to warrant a conversion for it, since technically we've already converted to RGB.

kevinSuttle commented 8 years ago

Ah that's a good point. Are there output formats (as opposed to conversions)?

Qix- commented 8 years ago

Not at the present moment. That's more color's thing.

kevinSuttle commented 8 years ago

Aha I see. Thanks @Qix-!

Qix- commented 8 years ago

No problem :) Keep 'em coming!