Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
use r, g, b, a components instead of rgb or rgba
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Feb 23, 2017
1 parent db11e1e commit b122802
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions templates/colors-default.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ extension Color {
{% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
enum {{enumName}} {
{% for color in colors %}
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.rgb}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.rgba}})
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.red}}{{color.green}}{{color.blue}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}})
case {{color.name|swiftIdentifier|escapeReservedKeywords}}
{% endfor %}

var rgbaValue: UInt32 {
switch self {
{% for color in colors %}
case .{{color.name|swiftIdentifier|escapeReservedKeywords}}:
return 0x{{color.rgba}}
return 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}
{% endfor %}
}
}
Expand Down
6 changes: 3 additions & 3 deletions templates/colors-rawValue.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ extension Color {
{% set enumName %}{{param.enumName|default:"ColorName"|swiftIdentifier}}{% endset %}
enum {{enumName}}: UInt32 {
{% for color in colors %}
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.rgb}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.rgba}})
case {{color.name|swiftIdentifier|escapeReservedKeywords}} = 0x{{color.rgba}}
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.red}}{{color.green}}{{color.blue}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}})
case {{color.name|swiftIdentifier|escapeReservedKeywords}} = 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}
{% endfor %}

var color: Color {
Expand Down
6 changes: 3 additions & 3 deletions templates/colors-swift3.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ extension Color {
{% set enumName %}{{param.enumName|default:"ColorName"}}{% endset %}
enum {{enumName}} {
{% for color in colors %}
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.rgb}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.rgba}})
/// <span style="display:block;width:3em;height:2em;border:1px solid black;background:#{{color.red}}{{color.green}}{{color.blue}}"></span>
/// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}} <br/> (0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}})
case {{color.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}
{% endfor %}

var rgbaValue: UInt32 {
switch self {
{% for color in colors %}
case .{{color.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}:
return 0x{{color.rgba}}
return 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}
{% endfor %}
}
}
Expand Down

0 comments on commit b122802

Please sign in to comment.