Class: RedBird::UIBox::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/red_bird/uibox.rb

Overview

A style defines the visual appearance of a Box.

Author:

  • Frederico Linhares

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(texture_file, texture_palette, bg_color, sprite_width, sprite_height) ⇒ Style

Returns a new instance of Style.

Parameters:

  • texture_file (String)

    path to a image file in the format required by this class.

  • bg_color (RedBird::Color)

    color used to fill the background of the box.

  • sprite_width (Integer)

    width of each sprite in the texture_file.

  • sprite_height (Integer)

    height of each sprite in the texture_file.

Author:

  • Frederico Linhares



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/red_bird/uibox.rb', line 33

def initialize(texture_file, texture_palette, bg_color, sprite_width,
               sprite_height)
  @texture = Texture.new(texture_file, texture_palette)
  @bg_color = bg_color
  @sprite_width = sprite_width
  @sprite_height = sprite_height

  @sprites = {}
  @sprites[:arrow_select] = Sprite.new(
    @texture, 1 * @sprite_width, 1 * @sprite_height,
    @sprite_width, @sprite_height)
  @sprites[:box_top_left] = Sprite.new(
    @texture, 0, 0, @sprite_width, @sprite_height)
  @sprites[:box_top] = Sprite.new(
    @texture, 1 * @sprite_width, 0,
    @sprite_width, @sprite_height)
  @sprites[:box_top_right] = Sprite.new(
    @texture, 2 * @sprite_height, 0,
    @sprite_width, @sprite_height)
  @sprites[:box_left] = Sprite.new(
    @texture, 0, 1 * @sprite_height,
    @sprite_width, @sprite_height)
  @sprites[:box_right] = Sprite.new(
    @texture, 2 * @sprite_width, 1 * @sprite_height,
    @sprite_width, @sprite_height)
  @sprites[:box_bottom_left] = Sprite.new(
    @texture, 0, 2 * @sprite_height,
    @sprite_width, @sprite_height)
  @sprites[:box_bottom] = Sprite.new(
    @texture, 1 * @sprite_width, 2 * @sprite_height,
    @sprite_width, @sprite_height)
  @sprites[:box_bottom_right] = Sprite.new(
    @texture, 2 * @sprite_width, 2 * @sprite_height,
    @sprite_width, @sprite_height)
end

Instance Attribute Details

#bg_colorRedBird::Color (readonly)

Returns:



22
# File 'lib/red_bird/uibox.rb', line 22

attr_reader :texture, :bg_color, :sprites, :sprite_width, :sprite_height

#sprite_heightObject (readonly)

Returns the value of attribute sprite_height.



22
# File 'lib/red_bird/uibox.rb', line 22

attr_reader :texture, :bg_color, :sprites, :sprite_width, :sprite_height

#sprite_widthInteger (readonly)

Returns:

  • (Integer)


22
# File 'lib/red_bird/uibox.rb', line 22

attr_reader :texture, :bg_color, :sprites, :sprite_width, :sprite_height

#spritesArray<RedBird::Sprite> (readonly)

Returns:



22
# File 'lib/red_bird/uibox.rb', line 22

attr_reader :texture, :bg_color, :sprites, :sprite_width, :sprite_height

#textureRedBird::Texture (readonly)

Returns:



22
23
24
# File 'lib/red_bird/uibox.rb', line 22

def texture
  @texture
end