Class: Reight::MapEditor::Brush

Inherits:
BrushBase show all
Defined in:
lib/reight/app/map/brush.rb

Instance Attribute Summary

Attributes inherited from Tool

#app

Attributes inherited from Button

#icon, #label, #name

Instance Method Summary collapse

Methods inherited from BrushBase

#canvas_clicked, #canvas_dragged, #canvas_moved, #put_or_remove_chip, #update_cursor

Methods inherited from Tool

#canvas, #canvas_clicked, #canvas_dragged, #canvas_moved, #chips, #history, #name, #pick_chip

Methods inherited from Button

#click, #disabled?, #disabled_icon, #draw, #enabled?, #hover, #pressed, #pressing?, #released, #sprite

Methods included from HasHelp

#help, #name, #set_help

Methods included from Hookable

#hook

Methods included from Activatable

#activated, #activated!, #active=, #active?

Constructor Details

#initialize(app, &block) ⇒ Brush

Returns a new instance of Brush.



6
7
8
9
# File 'lib/reight/app/map/brush.rb', line 6

def initialize(app, &block)
  super app, icon: app.icon(1, 2, 8), &block
  set_help left: name, right: 'Pick Chip'
end

Instance Method Details

#brush(cursor_from, cursor_to, chip) ⇒ Object



11
12
13
14
15
# File 'lib/reight/app/map/brush.rb', line 11

def brush(cursor_from, cursor_to, chip)
  x, y, = cursor_to
  put_or_remove_chip x, y, chip
  false
end

#canvas_pressedObject



17
18
19
20
# File 'lib/reight/app/map/brush.rb', line 17

def canvas_pressed(...)
  canvas.begin_editing
  super
end

#canvas_releasedObject



22
23
24
25
# File 'lib/reight/app/map/brush.rb', line 22

def canvas_released(...)
  super
  canvas.end_editing
end