Class: Reight::SpriteEditor::Brush
- Defined in:
- lib/reight/app/sprite/brush.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
Returns the value of attribute size.
Attributes inherited from Tool
Attributes inherited from Button
Instance Method Summary collapse
- #brush(x, y, button) ⇒ Object
- #canvas_clicked(x, y, button) ⇒ Object
- #canvas_dragged(x, y, button) ⇒ Object
- #canvas_pressed(x, y, button) ⇒ Object
- #canvas_released(x, y, button) ⇒ Object
-
#initialize(app, &block) ⇒ Brush
constructor
A new instance of Brush.
Methods inherited from Tool
#canvas, #canvas_moved, #history, #pick_color
Methods inherited from Button
#click, #disabled?, #disabled_icon, #draw, #enabled?, #hover, #pressed, #pressing?, #released, #sprite
Methods included from HasHelp
Methods included from Hookable
Methods included from Activatable
#activated, #activated!, #active=, #active?
Constructor Details
#initialize(app, &block) ⇒ Brush
Returns a new instance of Brush.
6 7 8 9 10 |
# File 'lib/reight/app/sprite/brush.rb', line 6 def initialize(app, &block) super app, icon: app.icon(1, 2, 8), &block @size = 1 set_help left: 'Brush', right: 'Pick Color' end |
Instance Attribute Details
#size ⇒ Object
Returns the value of attribute size.
12 13 14 |
# File 'lib/reight/app/sprite/brush.rb', line 12 def size @size end |
Instance Method Details
#brush(x, y, button) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/reight/app/sprite/brush.rb', line 14 def brush(x, y, ) canvas.paint do |g| g.no_fill g.stroke(*canvas.color) g.stroke_weight size g.point x, y end end |
#canvas_clicked(x, y, button) ⇒ Object
39 40 41 |
# File 'lib/reight/app/sprite/brush.rb', line 39 def canvas_clicked(x, y, ) pick_color x, y if == RIGHT end |
#canvas_dragged(x, y, button) ⇒ Object
34 35 36 37 |
# File 'lib/reight/app/sprite/brush.rb', line 34 def canvas_dragged(x, y, ) return unless == LEFT brush x, y, end |
#canvas_pressed(x, y, button) ⇒ Object
23 24 25 26 27 |
# File 'lib/reight/app/sprite/brush.rb', line 23 def canvas_pressed(x, y, ) return unless == LEFT canvas.begin_editing brush x, y, end |
#canvas_released(x, y, button) ⇒ Object
29 30 31 32 |
# File 'lib/reight/app/sprite/brush.rb', line 29 def canvas_released(x, y, ) return unless == LEFT canvas.end_editing end |