Class: Smalruby::Canvas
Overview
Direct Known Subclasses
Stage
Instance Attribute Summary
Attributes inherited from Character
#angle, #checking_hit_targets, #event_handlers, #threads
Instance Method Summary
collapse
Methods inherited from Character
#alive?, #button, #button_down, #button_up, #click, #distance, #draw, #hit, #hit?, #join, #key_down, #key_push, #led, #loop, #move, #move_back, #on, #play, #point_towards, #reach_wall?, #rgb_led_anode, #rgb_led_cathode, #rotate, #say, #sensor, #sensor_change, #servo, #start, #turn, #turn_if_reach_wall, #two_wheel_drive_car
Constructor Details
#initialize(options = {}) ⇒ Canvas
Returns a new instance of Canvas.
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/smalruby/canvas.rb', line 6
def initialize(options = {})
defaults = {
x: 0,
y: 0,
width: Window.width,
height: Window.height
}
opts = Util.process_options(options, defaults)
opts[:costume] = Image.new(opts[:width], opts[:height])
super(opts.reject { |k, v| [:width, :height].include?(k) })
end
|
Instance Method Details
#box(option) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/smalruby/canvas.rb', line 41
def box(option)
opt = process_rect_option(option)
image.box(opt[:left], opt[:top], opt[:right], opt[:bottom],
Color.smalruby_to_dxruby(opt[:color]))
end
|
#box_fill(option) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/smalruby/canvas.rb', line 48
def box_fill(option)
opt = process_rect_option(option)
image.box_fill(opt[:left], opt[:top], opt[:right], opt[:bottom],
Color.smalruby_to_dxruby(opt[:color]))
end
|
#circle(option) ⇒ Object
55
56
57
58
59
60
|
# File 'lib/smalruby/canvas.rb', line 55
def circle(option)
opt = process_circle_option(option)
image.circle(opt[:x], opt[:y], opt[:r],
Color.smalruby_to_dxruby(opt[:color]))
end
|
#circle_fill(option) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/smalruby/canvas.rb', line 62
def circle_fill(option)
opt = process_circle_option(option)
image.circle_fill(opt[:x], opt[:y], opt[:r],
Color.smalruby_to_dxruby(opt[:color]))
end
|
#draw_font(option) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/smalruby/canvas.rb', line 21
def draw_font(option)
defaults = {
x: 0,
y: 0,
string: "",
size: 32
}.merge(DEFAULT_COLOR_OPTION)
opt = process_optional_arguments(option, defaults)
image.draw_font(opt[:x], opt[:y], opt[:string], new_font(opt[:size]),
Color.smalruby_to_dxruby(opt[:color]))
end
|
#fill(option) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/smalruby/canvas.rb', line 69
def fill(option)
opt = process_optional_arguments(option, DEFAULT_COLOR_OPTION)
image.box_fill(0, 0, image.width, image.height,
Color.smalruby_to_dxruby(opt[:color]))
end
|
#line(option) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/smalruby/canvas.rb', line 34
def line(option)
opt = process_rect_option(option)
image.line(opt[:left], opt[:top], opt[:right], opt[:bottom],
Color.smalruby_to_dxruby(opt[:color]))
end
|