Class: Hokusai::Commands

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeCommands

Returns a new instance of Commands.



12
13
14
# File 'ui/src/hokusai/commands.rb', line 12

def initialize
  # @queue = []
end

Instance Attribute Details

#queueObject (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

Yields:

  • (command)


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

#eachObject



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

Yields:

  • (command)


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_endObject

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

#svg(source, x, y, w, h) {|command| ... } ⇒ Object

Yields:

  • (command)


36
37
38
39
40
41
# File 'ui/src/hokusai/commands.rb', line 36

def svg(source, x, y, w, h)
  command = Commands::SVG.new(source, x, y, w, h)
  yield(command)

  # add(command)
end

#text(content, x, y) {|command| ... } ⇒ Object

Yields:

  • (command)


63
64
65
66
67
68
69
# File 'ui/src/hokusai/commands.rb', line 63

def text(content, x, y)
  command = Commands::Text.new(content, x, y)
  yield command

  command.draw
  # add(command)
end