Method: MiniGL::Button#draw
- Defined in:
- lib/minigl/forms.rb
#draw(alpha = 0xff, z_index = 0) ⇒ Object
Draws the button in the screen.
Parameters:
- alpha
-
The opacity with which the button will be drawn. Allowed values vary between 0 (fully transparent) and 255 (fully opaque).
- z_index
-
The z-order to draw the object. Objects with larger z-orders will be drawn on top of the ones with smaller z-orders.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/minigl/forms.rb', line 220 def draw(alpha = 0xff, z_index = 0) return unless @visible color = (alpha << 24) | 0xffffff text_color = if @enabled if @state == :down @down_text_color else @state == :over ? @over_text_color : @text_color end else @disabled_text_color end text_color = (alpha << 24) | text_color @img[@img_index].draw @x, @y, z_index, 1, 1, color if @img if @text if @center_x or @center_y rel_x = @center_x ? 0.5 : 0 rel_y = @center_y ? 0.5 : 0 @font.draw_rel @text, @text_x, @text_y, z_index, rel_x, rel_y, 1, 1, text_color else @font.draw @text, @text_x, @text_y, z_index, 1, 1, text_color end end end |