Class: Hokusai::Commands
- Inherits:
-
Object
- Object
- Hokusai::Commands
- Defined in:
- ui/src/hokusai/commands.rb,
ui/src/hokusai/commands/base.rb
Defined Under Namespace
Classes: Base, Circle, Image, Rect, SVG, ScissorBegin, ScissorEnd, Text
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #add(command) ⇒ Object
- #circle(x, y, radius) {|command| ... } ⇒ Object
- #clear! ⇒ Object
- #each ⇒ Object
-
#image(source, x, y, w, h) ⇒ Object
Invokes an image command from a filename, at position x,y with ‘w`x`h` dimensions.
-
#initialize ⇒ Commands
constructor
A new instance of Commands.
-
#rect(x, y, w, h) {|command| ... } ⇒ Object
def hash [self.class, *@queue.map(&:hash)].hash end.
-
#scissor_begin(x, y, w, h) ⇒ Object
Invokes a scissor begin command at position x,y with ‘w`x`h` dimensions.
-
#scissor_end ⇒ Object
Invokes a scissor stop command.
- #svg(source, x, y, w, h) {|command| ... } ⇒ Object
- #text(content, x, y) {|command| ... } ⇒ Object
Constructor Details
#initialize ⇒ Commands
Returns a new instance of Commands.
12 13 14 |
# File 'ui/src/hokusai/commands.rb', line 12 def initialize # @queue = [] end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
10 11 12 |
# File 'ui/src/hokusai/commands.rb', line 10 def queue @queue end |
Instance Method Details
#add(command) ⇒ Object
81 82 83 84 85 |
# File 'ui/src/hokusai/commands.rb', line 81 def add(command) # @queue << command self end |
#circle(x, y, radius) {|command| ... } ⇒ Object
28 29 30 31 32 33 34 |
# File 'ui/src/hokusai/commands.rb', line 28 def circle(x, y, radius) command = Commands::Circle.new(x, y, radius) yield(command) command.draw # add(command) end |
#clear! ⇒ Object
77 78 79 |
# File 'ui/src/hokusai/commands.rb', line 77 def clear! # @queue = [] end |
#each ⇒ Object
71 72 73 74 75 |
# File 'ui/src/hokusai/commands.rb', line 71 def each queue.each do |cmd| yield(cmd) end end |
#image(source, x, y, w, h) ⇒ Object
Invokes an image command from a filename, at position x,y with ‘w`x`h` dimensions
45 46 47 48 |
# File 'ui/src/hokusai/commands.rb', line 45 def image(source, x, y, w, h) Commands::Image.new(source, x, y, w, h).draw # add(Commands::Image.new(source, x, y, w, h)) end |
#rect(x, y, w, h) {|command| ... } ⇒ Object
def hash
[self.class, *@queue.map(&:hash)].hash
end
20 21 22 23 24 25 26 |
# File 'ui/src/hokusai/commands.rb', line 20 def rect(x, y, w, h) command = Commands::Rect.new(x, y, w, h) yield(command) command.draw # add(command) end |
#scissor_begin(x, y, w, h) ⇒ Object
Invokes a scissor begin command at position x,y with ‘w`x`h` dimensions
52 53 54 55 |
# File 'ui/src/hokusai/commands.rb', line 52 def scissor_begin(x, y, w, h) Commands::ScissorBegin.new(x, y, w, h).draw # add(Commands::ScissorBegin.new(x, y, w, h)) end |
#scissor_end ⇒ Object
Invokes a scissor stop command
58 59 60 61 |
# File 'ui/src/hokusai/commands.rb', line 58 def scissor_end Commands::ScissorEnd.new.draw # add(Commands::ScissorEnd.new) end |