Module: Shoes::Color::DSLHelpers
Instance Method Summary
collapse
#absolute_file_path, #default_search_paths, #search_for
Instance Method Details
#color(arg) ⇒ Object
28
29
30
|
# File 'shoes-core/lib/shoes/color/dsl_helpers.rb', line 28
def color(arg)
Shoes::Color.create(arg)
end
|
#gradient(from, to) ⇒ Object
#gradient(from, to) ⇒ Object
#gradient(range) ⇒ Object
#gradient(range) ⇒ Object
Creates a new Shoes::Gradient
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'shoes-core/lib/shoes/color/dsl_helpers.rb', line 51
def gradient(*args)
case args.length
when 1
arg = args[0]
case arg
when Gradient
min = arg.color1
max = arg.color2
when Range
min = arg.first
max = arg.last
else
raise ArgumentError, "Can't make gradient out of #{arg.inspect}"
end
when 2
min = args[0]
max = args[1]
else
raise ArgumentError, "Wrong number of arguments (#{args.length} for 1 or 2)"
end
Shoes::Gradient.new(color(min), color(max))
end
|
#gray(level = 128, alpha = Shoes::Color::OPAQUE) ⇒ Object
Also known as:
grey
74
75
76
|
# File 'shoes-core/lib/shoes/color/dsl_helpers.rb', line 74
def gray(level = 128, alpha = Shoes::Color::OPAQUE)
Shoes::Color.new(level, level, level, alpha)
end
|
#pattern(*args) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'shoes-core/lib/shoes/color/dsl_helpers.rb', line 8
def pattern(*args)
if args.length == 1
arg = args.first
case arg
when String
image_file?(arg) ? image_pattern(arg) : color(arg)
when Shoes::Color
color arg
when Range, Shoes::Gradient
gradient(arg)
when Shoes::ImagePattern
arg
else
raise ArgumentError, "Bad pattern: #{arg.inspect}"
end
else
gradient(*args)
end
end
|
#rgb(red, green, blue, alpha = Shoes::Color::OPAQUE) ⇒ Object
32
33
34
|
# File 'shoes-core/lib/shoes/color/dsl_helpers.rb', line 32
def rgb(red, green, blue, alpha = Shoes::Color::OPAQUE)
Shoes::Color.new(red, green, blue, alpha)
end
|