Class: Shoes::Background
Instance Attribute Summary collapse
-
#first ⇒ Object
Returns the value of attribute first.
-
#last ⇒ Object
Returns the value of attribute last.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
- #b(color) ⇒ Object
-
#draw(painter) ⇒ Object
draws the background.
- #g(color) ⇒ Object
-
#initialize(pattern, style) ⇒ Background
constructor
A new instance of Background.
- #r(color) ⇒ Object
-
#to_pattern ⇒ Object
Yanks out the color, gradient or image used to paint this background and places it in a normal Shoes::Pattern object.
Constructor Details
#initialize(pattern, style) ⇒ Background
Returns a new instance of Background.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blue_shoes/pattern.rb', line 10 def initialize(pattern, style) if pattern.first.length == 4 f = pattern.first self.first = "#" + (f[1,1] * 2) + (f[2,1] * 2) + (f[3,1] * 2) else self.first = pattern.first end if pattern.last.length == 4 l = pattern.last self.last = "#" + (l[1,1] * 2) + (l[2,1] * 2) + (l[3,1] * 2) else self.last = pattern.last end self.style = style end |
Instance Attribute Details
#first ⇒ Object
Returns the value of attribute first.
6 7 8 |
# File 'lib/blue_shoes/pattern.rb', line 6 def first @first end |
#last ⇒ Object
Returns the value of attribute last.
7 8 9 |
# File 'lib/blue_shoes/pattern.rb', line 7 def last @last end |
#style ⇒ Object
Returns the value of attribute style.
8 9 10 |
# File 'lib/blue_shoes/pattern.rb', line 8 def style @style end |
Instance Method Details
#b(color) ⇒ Object
32 33 34 |
# File 'lib/blue_shoes/pattern.rb', line 32 def b color color[5,2].to_i 16 end |
#draw(painter) ⇒ Object
draws the background
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/blue_shoes/pattern.rb', line 37 def draw painter painter.setRenderHint Qt::Painter::Antialiasing painter.setPen Qt::NoPen painter.setBrush Qt::HorPattern gradient = Qt::LinearGradient.new(0, 0, 0, 100) bottom = Qt::Color.new(r(first),g(first),b(first)) top = Qt::Color.new(r(last),g(last),b(last)) gradient.setColorAt(0.0, bottom) gradient.setColorAt(1.0, top) painter.setBrush(Qt::Brush.new(gradient)) window = painter.window window.setLeft(window.left + style[:margin]) window.setTop(window.top + style[:margin]) window.setHeight(window.height - style[:margin]) window.setWidth(window.width - style[:margin]) painter.drawRoundRect(window, style[:curve], style[:curve]) end |
#g(color) ⇒ Object
29 30 31 |
# File 'lib/blue_shoes/pattern.rb', line 29 def g color color[3,2].to_i 16 end |
#r(color) ⇒ Object
26 27 28 |
# File 'lib/blue_shoes/pattern.rb', line 26 def r color color[1,2].to_i 16 end |
#to_pattern ⇒ Object
Yanks out the color, gradient or image used to paint this background and places it in a normal Shoes::Pattern object.
56 57 58 59 |
# File 'lib/blue_shoes/pattern.rb', line 56 def to_pattern # returns a Shoes::Pattern throw NotImplementedError end |