Class: UI::Color

Inherits:
Object show all
Defined in:
flow/ui/color.rb

Overview

Represents a color. Can be initialized in several ways:

- With a hex number:
  UI::Color.hex("#d2603c")
- With RGB values:
  UI::Color.rgb(123, 200, 78)
- Using one of the preset colors

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Color) initialize(proxy)

Returns a new instance of Color



38
39
40
# File 'flow/ui/color.rb', line 38

def initialize(proxy)
  @proxy = proxy
end

Instance Attribute Details

- (Object) proxy (readonly)

Returns the value of attribute proxy



37
38
39
# File 'flow/ui/color.rb', line 37

def proxy
  @proxy
end

Class Method Details

+ (Object) alice_blue



73
# File 'flow/ui/color.rb', line 73

def self.alice_blue; hex("#F0F8FF"); end

+ (Object) antique_white



74
# File 'flow/ui/color.rb', line 74

def self.antique_white; hex("#FAEBD7"); end

+ (Object) aqua



75
# File 'flow/ui/color.rb', line 75

def self.aqua; hex("#00FFFF"); end

+ (Object) aquamarine



76
# File 'flow/ui/color.rb', line 76

def self.aquamarine; hex("#7FFFD4"); end

+ (Object) azure



77
# File 'flow/ui/color.rb', line 77

def self.azure; hex("#F0FFFF"); end

+ (Object) beige



78
# File 'flow/ui/color.rb', line 78

def self.beige; hex("#F5F5DC"); end

+ (Object) bisque



79
# File 'flow/ui/color.rb', line 79

def self.bisque; hex("#FFE4C4"); end

+ (Object) black



80
# File 'flow/ui/color.rb', line 80

def self.black; hex("#000000"); end

+ (Object) blanched_almond



81
# File 'flow/ui/color.rb', line 81

def self.blanched_almond; hex("#FFEBCD"); end

+ (Object) blue



82
# File 'flow/ui/color.rb', line 82

def self.blue; hex("#0000FF"); end

+ (Object) blue_violet



83
# File 'flow/ui/color.rb', line 83

def self.blue_violet; hex("#8A2BE2"); end

+ (Object) brown



84
# File 'flow/ui/color.rb', line 84

def self.brown; hex("#A52A2A"); end

+ (Object) burly_wood



85
# File 'flow/ui/color.rb', line 85

def self.burly_wood; hex("#DEB887"); end

+ (Object) cadet_blue



86
# File 'flow/ui/color.rb', line 86

def self.cadet_blue; hex("#5F9EA0"); end

+ (Object) chartreuse



87
# File 'flow/ui/color.rb', line 87

def self.chartreuse; hex("#7FFF00"); end

+ (Object) chocolate



88
# File 'flow/ui/color.rb', line 88

def self.chocolate; hex("#D2691E"); end

+ (Object) clear



71
# File 'flow/ui/color.rb', line 71

def self.clear; rgba(0, 0, 0, 0); end

+ (Object) coral



89
# File 'flow/ui/color.rb', line 89

def self.coral; hex("#FF7F50"); end

+ (Object) cornflower_blue



90
# File 'flow/ui/color.rb', line 90

def self.cornflower_blue; hex("#6495ED"); end

+ (Object) cornsilk



91
# File 'flow/ui/color.rb', line 91

def self.cornsilk; hex("#FFF8DC"); end

+ (Object) crimson



92
# File 'flow/ui/color.rb', line 92

def self.crimson; hex("#DC143C"); end

+ (Object) cyan



93
# File 'flow/ui/color.rb', line 93

def self.cyan; hex("#00FFFF"); end

+ (Object) dark_blue



94
# File 'flow/ui/color.rb', line 94

def self.dark_blue; hex("#00008B"); end

+ (Object) dark_cyan



95
# File 'flow/ui/color.rb', line 95

def self.dark_cyan; hex("#008B8B"); end

+ (Object) dark_golden_rod



96
# File 'flow/ui/color.rb', line 96

def self.dark_golden_rod; hex("#B8860B"); end

+ (Object) dark_gray



97
# File 'flow/ui/color.rb', line 97

def self.dark_gray; hex("#A9A9A9"); end

+ (Object) dark_green



99
# File 'flow/ui/color.rb', line 99

def self.dark_green; hex("#006400"); end

+ (Object) dark_grey



98
# File 'flow/ui/color.rb', line 98

def self.dark_grey; hex("#A9A9A9"); end

+ (Object) dark_khaki



100
# File 'flow/ui/color.rb', line 100

def self.dark_khaki; hex("#BDB76B"); end

+ (Object) dark_magenta



101
# File 'flow/ui/color.rb', line 101

def self.dark_magenta; hex("#8B008B"); end

+ (Object) dark_olive_green



102
# File 'flow/ui/color.rb', line 102

def self.dark_olive_green; hex("#556B2F"); end

+ (Object) dark_orange



103
# File 'flow/ui/color.rb', line 103

def self.dark_orange; hex("#FF8C00"); end

+ (Object) dark_orchid



104
# File 'flow/ui/color.rb', line 104

def self.dark_orchid; hex("#9932CC"); end

+ (Object) dark_red



105
# File 'flow/ui/color.rb', line 105

def self.dark_red; hex("#8B0000"); end

+ (Object) dark_salmon



106
# File 'flow/ui/color.rb', line 106

def self.dark_salmon; hex("#E9967A"); end

+ (Object) dark_sea_green



107
# File 'flow/ui/color.rb', line 107

def self.dark_sea_green; hex("#8FBC8F"); end

+ (Object) dark_slate_blue



108
# File 'flow/ui/color.rb', line 108

def self.dark_slate_blue; hex("#483D8B"); end

+ (Object) dark_slate_gray



109
# File 'flow/ui/color.rb', line 109

def self.dark_slate_gray; hex("#2F4F4F"); end

+ (Object) dark_slate_grey



110
# File 'flow/ui/color.rb', line 110

def self.dark_slate_grey; hex("#2F4F4F"); end

+ (Object) dark_turquoise



111
# File 'flow/ui/color.rb', line 111

def self.dark_turquoise; hex("#00CED1"); end

+ (Object) dark_violet



112
# File 'flow/ui/color.rb', line 112

def self.dark_violet; hex("#9400D3"); end

+ (Object) deep_pink



113
# File 'flow/ui/color.rb', line 113

def self.deep_pink; hex("#FF1493"); end

+ (Object) deep_sky_blue



114
# File 'flow/ui/color.rb', line 114

def self.deep_sky_blue; hex("#00BFFF"); end

+ (Object) dim_gray



115
# File 'flow/ui/color.rb', line 115

def self.dim_gray; hex("#696969"); end

+ (Object) dim_grey



116
# File 'flow/ui/color.rb', line 116

def self.dim_grey; hex("#696969"); end

+ (Object) dodger_blue



117
# File 'flow/ui/color.rb', line 117

def self.dodger_blue; hex("#1E90FF"); end

+ (Object) fire_brick



118
# File 'flow/ui/color.rb', line 118

def self.fire_brick; hex("#B22222"); end

+ (Object) floral_white



119
# File 'flow/ui/color.rb', line 119

def self.floral_white; hex("#FFFAF0"); end

+ (Object) forest_green



120
# File 'flow/ui/color.rb', line 120

def self.forest_green; hex("#228B22"); end

+ (Object) fuchsia



121
# File 'flow/ui/color.rb', line 121

def self.fuchsia; hex("#FF00FF"); end

+ (Object) gainsboro



122
# File 'flow/ui/color.rb', line 122

def self.gainsboro; hex("#DCDCDC"); end

+ (Object) ghost_white



123
# File 'flow/ui/color.rb', line 123

def self.ghost_white; hex("#F8F8FF"); end

+ (Object) gold



124
# File 'flow/ui/color.rb', line 124

def self.gold; hex("#FFD700"); end

+ (Object) golden_rod



125
# File 'flow/ui/color.rb', line 125

def self.golden_rod; hex("#DAA520"); end

+ (Object) gray



126
# File 'flow/ui/color.rb', line 126

def self.gray; hex("#808080"); end

+ (Object) green



128
# File 'flow/ui/color.rb', line 128

def self.green; hex("#008000"); end

+ (Object) green_yellow



129
# File 'flow/ui/color.rb', line 129

def self.green_yellow; hex("#ADFF2F"); end

+ (Object) grey



127
# File 'flow/ui/color.rb', line 127

def self.grey; hex("#808080"); end

+ (Object) hex(hex_color)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'flow/ui/color.rb', line 46

def self.hex(hex_color)
  hex_color.gsub!("#", "")

  colors =  case hex_color.size
              when 3
                hex_color.scan(%r{[0-9A-Fa-f]}).map!{ |el| (el * 2).to_i(16) }
              when 6, 8
                hex_color.scan(%r<[0-9A-Fa-f]{2}>).map!{ |el| el.to_i(16) }
              else
                raise ArgumentError
            end

  if colors.size == 3
    rgb(*colors)
  elsif colors.size == 4
    rgba(*colors[1..3], colors[0])
  else
    raise ArgumentError
  end
end

+ (Object) honey_dew



130
# File 'flow/ui/color.rb', line 130

def self.honey_dew; hex("#F0FFF0"); end

+ (Object) hot_pink



131
# File 'flow/ui/color.rb', line 131

def self.hot_pink; hex("#FF69B4"); end

+ (Object) indian_red



132
# File 'flow/ui/color.rb', line 132

def self.indian_red; hex("#CD5C5C"); end

+ (Object) indigo



133
# File 'flow/ui/color.rb', line 133

def self.indigo; hex("#4B0082"); end

+ (Object) ivory



134
# File 'flow/ui/color.rb', line 134

def self.ivory; hex("#FFFFF0"); end

+ (Object) khaki



135
# File 'flow/ui/color.rb', line 135

def self.khaki; hex("#F0E68C"); end

+ (Object) lavender



136
# File 'flow/ui/color.rb', line 136

def self.lavender; hex("#E6E6FA"); end

+ (Object) lavender_blush



137
# File 'flow/ui/color.rb', line 137

def self.lavender_blush; hex("#FFF0F5"); end

+ (Object) lawn_green



138
# File 'flow/ui/color.rb', line 138

def self.lawn_green; hex("#7CFC00"); end

+ (Object) lemon_chiffon



139
# File 'flow/ui/color.rb', line 139

def self.lemon_chiffon; hex("#FFFACD"); end

+ (Object) light_blue



140
# File 'flow/ui/color.rb', line 140

def self.light_blue; hex("#ADD8E6"); end

+ (Object) light_coral



141
# File 'flow/ui/color.rb', line 141

def self.light_coral; hex("#F08080"); end

+ (Object) light_cyan



142
# File 'flow/ui/color.rb', line 142

def self.light_cyan; hex("#E0FFFF"); end

+ (Object) light_golden_rod_yellow



143
# File 'flow/ui/color.rb', line 143

def self.light_golden_rod_yellow; hex("#FAFAD2"); end

+ (Object) light_gray



144
# File 'flow/ui/color.rb', line 144

def self.light_gray; hex("#D3D3D3"); end

+ (Object) light_green



146
# File 'flow/ui/color.rb', line 146

def self.light_green; hex("#90EE90"); end

+ (Object) light_grey



145
# File 'flow/ui/color.rb', line 145

def self.light_grey; hex("#D3D3D3"); end

+ (Object) light_pink



147
# File 'flow/ui/color.rb', line 147

def self.light_pink; hex("#FFB6C1"); end

+ (Object) light_salmon



148
# File 'flow/ui/color.rb', line 148

def self.light_salmon; hex("#FFA07A"); end

+ (Object) light_sea_green



149
# File 'flow/ui/color.rb', line 149

def self.light_sea_green; hex("#20B2AA"); end

+ (Object) light_sky_blue



150
# File 'flow/ui/color.rb', line 150

def self.light_sky_blue; hex("#87CEFA"); end

+ (Object) light_slate_gray



151
# File 'flow/ui/color.rb', line 151

def self.light_slate_gray; hex("#778899"); end

+ (Object) light_slate_grey



152
# File 'flow/ui/color.rb', line 152

def self.light_slate_grey; hex("#778899"); end

+ (Object) light_steel_blue



153
# File 'flow/ui/color.rb', line 153

def self.light_steel_blue; hex("#B0C4DE"); end

+ (Object) light_yellow



154
# File 'flow/ui/color.rb', line 154

def self.light_yellow; hex("#FFFFE0"); end

+ (Object) lime



155
# File 'flow/ui/color.rb', line 155

def self.lime; hex("#00FF00"); end

+ (Object) lime_green



156
# File 'flow/ui/color.rb', line 156

def self.lime_green; hex("#32CD32"); end

+ (Object) linen



157
# File 'flow/ui/color.rb', line 157

def self.linen; hex("#FAF0E6"); end

+ (Object) magenta



158
# File 'flow/ui/color.rb', line 158

def self.magenta; hex("#FF00FF"); end

+ (Object) maroon



159
# File 'flow/ui/color.rb', line 159

def self.maroon; hex("#800000"); end

+ (Object) medium_aqua_marine



160
# File 'flow/ui/color.rb', line 160

def self.medium_aqua_marine; hex("#66CDAA"); end

+ (Object) medium_blue



161
# File 'flow/ui/color.rb', line 161

def self.medium_blue; hex("#0000CD"); end

+ (Object) medium_orchid



162
# File 'flow/ui/color.rb', line 162

def self.medium_orchid; hex("#BA55D3"); end

+ (Object) medium_purple



163
# File 'flow/ui/color.rb', line 163

def self.medium_purple; hex("#9370DB"); end

+ (Object) medium_sea_green



164
# File 'flow/ui/color.rb', line 164

def self.medium_sea_green; hex("#3CB371"); end

+ (Object) medium_slate_blue



165
# File 'flow/ui/color.rb', line 165

def self.medium_slate_blue; hex("#7B68EE"); end

+ (Object) medium_spring_green



166
# File 'flow/ui/color.rb', line 166

def self.medium_spring_green; hex("#00FA9A"); end

+ (Object) medium_turquoise



167
# File 'flow/ui/color.rb', line 167

def self.medium_turquoise; hex("#48D1CC"); end

+ (Object) medium_violet_red



168
# File 'flow/ui/color.rb', line 168

def self.medium_violet_red; hex("#C71585"); end

+ (Object) midnight_blue



169
# File 'flow/ui/color.rb', line 169

def self.midnight_blue; hex("#191970"); end

+ (Object) mint_cream



170
# File 'flow/ui/color.rb', line 170

def self.mint_cream; hex("#F5FFFA"); end

+ (Object) misty_rose



171
# File 'flow/ui/color.rb', line 171

def self.misty_rose; hex("#FFE4E1"); end

+ (Object) moccasin



172
# File 'flow/ui/color.rb', line 172

def self.moccasin; hex("#FFE4B5"); end


173
# File 'flow/ui/color.rb', line 173

def self.navajo_white; hex("#FFDEAD"); end


174
# File 'flow/ui/color.rb', line 174

def self.navy; hex("#000080"); end

+ (Object) old_lace



175
# File 'flow/ui/color.rb', line 175

def self.old_lace; hex("#FDF5E6"); end

+ (Object) olive



176
# File 'flow/ui/color.rb', line 176

def self.olive; hex("#808000"); end

+ (Object) olive_drab



177
# File 'flow/ui/color.rb', line 177

def self.olive_drab; hex("#6B8E23"); end

+ (Object) orange



178
# File 'flow/ui/color.rb', line 178

def self.orange; hex("#FFA500"); end

+ (Object) orange_red



179
# File 'flow/ui/color.rb', line 179

def self.orange_red; hex("#FF4500"); end

+ (Object) orchid



180
# File 'flow/ui/color.rb', line 180

def self.orchid; hex("#DA70D6"); end

+ (Object) pale_golden_rod



181
# File 'flow/ui/color.rb', line 181

def self.pale_golden_rod; hex("#EEE8AA"); end

+ (Object) pale_green



182
# File 'flow/ui/color.rb', line 182

def self.pale_green; hex("#98FB98"); end

+ (Object) pale_turquoise



183
# File 'flow/ui/color.rb', line 183

def self.pale_turquoise; hex("#AFEEEE"); end

+ (Object) pale_violet_red



184
# File 'flow/ui/color.rb', line 184

def self.pale_violet_red; hex("#DB7093"); end

+ (Object) papaya_whip



185
# File 'flow/ui/color.rb', line 185

def self.papaya_whip; hex("#FFEFD5"); end

+ (Object) peach_puff



186
# File 'flow/ui/color.rb', line 186

def self.peach_puff; hex("#FFDAB9"); end

+ (Object) peru



187
# File 'flow/ui/color.rb', line 187

def self.peru; hex("#CD853F"); end

+ (Object) pink



188
# File 'flow/ui/color.rb', line 188

def self.pink; hex("#FFC0CB"); end

+ (Object) plum



189
# File 'flow/ui/color.rb', line 189

def self.plum; hex("#DDA0DD"); end

+ (Object) powder_blue



190
# File 'flow/ui/color.rb', line 190

def self.powder_blue; hex("#B0E0E6"); end

+ (Object) purple



191
# File 'flow/ui/color.rb', line 191

def self.purple; hex("#800080"); end

+ (Object) rebecca_purple



192
# File 'flow/ui/color.rb', line 192

def self.rebecca_purple; hex("#663399"); end

+ (Object) red



193
# File 'flow/ui/color.rb', line 193

def self.red; hex("#FF0000"); end

+ (Object) rgb(r, g, b)



67
68
69
# File 'flow/ui/color.rb', line 67

def self.rgb(r, g, b)
  rgba(r, g, b, 255)
end

+ (Object) rosy_brown



194
# File 'flow/ui/color.rb', line 194

def self.rosy_brown; hex("#BC8F8F"); end

+ (Object) royal_blue



195
# File 'flow/ui/color.rb', line 195

def self.royal_blue; hex("#4169E1"); end

+ (Object) saddle_brown



196
# File 'flow/ui/color.rb', line 196

def self.saddle_brown; hex("#8B4513"); end

+ (Object) salmon



197
# File 'flow/ui/color.rb', line 197

def self.salmon; hex("#FA8072"); end

+ (Object) sandy_brown



198
# File 'flow/ui/color.rb', line 198

def self.sandy_brown; hex("#F4A460"); end

+ (Object) sea_green



199
# File 'flow/ui/color.rb', line 199

def self.sea_green; hex("#2E8B57"); end

+ (Object) sea_shell



200
# File 'flow/ui/color.rb', line 200

def self.sea_shell; hex("#FFF5EE"); end

+ (Object) sienna



201
# File 'flow/ui/color.rb', line 201

def self.sienna; hex("#A0522D"); end

+ (Object) silver



202
# File 'flow/ui/color.rb', line 202

def self.silver; hex("#C0C0C0"); end

+ (Object) sky_blue



203
# File 'flow/ui/color.rb', line 203

def self.sky_blue; hex("#87CEEB"); end

+ (Object) slate_blue



204
# File 'flow/ui/color.rb', line 204

def self.slate_blue; hex("#6A5ACD"); end

+ (Object) slate_gray



205
# File 'flow/ui/color.rb', line 205

def self.slate_gray; hex("#708090"); end

+ (Object) slate_grey



206
# File 'flow/ui/color.rb', line 206

def self.slate_grey; hex("#708090"); end

+ (Object) snow



207
# File 'flow/ui/color.rb', line 207

def self.snow; hex("#FFFAFA"); end

+ (Object) spring_green



208
# File 'flow/ui/color.rb', line 208

def self.spring_green; hex("#00FF7F"); end

+ (Object) steel_blue



209
# File 'flow/ui/color.rb', line 209

def self.steel_blue; hex("#4682B4"); end

+ (Object) symbol(symbol)



42
43
44
# File 'flow/ui/color.rb', line 42

def self.symbol(symbol)
  send(symbol)
end

+ (Object) tan



210
# File 'flow/ui/color.rb', line 210

def self.tan; hex("#D2B48C"); end

+ (Object) teal



211
# File 'flow/ui/color.rb', line 211

def self.teal; hex("#008080"); end

+ (Object) thistle



212
# File 'flow/ui/color.rb', line 212

def self.thistle; hex("#D8BFD8"); end

+ (Object) tomato



213
# File 'flow/ui/color.rb', line 213

def self.tomato; hex("#FF6347"); end

+ (Object) turquoise



214
# File 'flow/ui/color.rb', line 214

def self.turquoise; hex("#40E0D0"); end

+ (Object) violet



215
# File 'flow/ui/color.rb', line 215

def self.violet; hex("#EE82EE"); end

+ (Object) wheat



216
# File 'flow/ui/color.rb', line 216

def self.wheat; hex("#F5DEB3"); end

+ (Object) white



217
# File 'flow/ui/color.rb', line 217

def self.white; hex("#FFFFFF"); end

+ (Object) white_smoke



218
# File 'flow/ui/color.rb', line 218

def self.white_smoke; hex("#F5F5F5"); end

+ (Object) yellow



219
# File 'flow/ui/color.rb', line 219

def self.yellow; hex("#FFFF00"); end

+ (Object) yellow_green



220
# File 'flow/ui/color.rb', line 220

def self.yellow_green; hex("#9ACD32"); end