Class: BLF::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/blf/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Block

Returns a new instance of Block.



8
9
10
11
12
13
14
# File 'lib/blf/block.rb', line 8

def initialize(args)
  @start_x = args[:start_x] || 0
  @start_y = args[:start_y] || 0
  @width = args[:width] || 0
  @height = args[:height] || 0
  @world = args[:world]
end

Instance Attribute Details

#end_xObject

Returns the value of attribute end_x.



6
7
8
# File 'lib/blf/block.rb', line 6

def end_x
  @end_x
end

#end_yObject

Returns the value of attribute end_y.



6
7
8
# File 'lib/blf/block.rb', line 6

def end_y
  @end_y
end

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/blf/block.rb', line 6

def height
  @height
end

#start_xObject

Returns the value of attribute start_x.



6
7
8
# File 'lib/blf/block.rb', line 6

def start_x
  @start_x
end

#start_yObject

Returns the value of attribute start_y.



6
7
8
# File 'lib/blf/block.rb', line 6

def start_y
  @start_y
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/blf/block.rb', line 6

def width
  @width
end

#worldObject

Returns the value of attribute world.



6
7
8
# File 'lib/blf/block.rb', line 6

def world
  @world
end

Instance Method Details

#drawObject



24
25
26
27
28
29
30
31
# File 'lib/blf/block.rb', line 24

def draw
  dr = Draw.new
  dr.stroke = "#ccddff"
  dr.fill = "rgb(#{random*255}, #{random*255}, #{random*255})"
  dr.stroke_width 1
  dr.rectangle @start_x, @start_y, end_x, end_y
  dr.draw @world.image
end

#randomObject



33
34
35
# File 'lib/blf/block.rb', line 33

def random
  Random.new(Random.new_seed).rand
end