Class: Reight::SpriteEditor::Line
- Defined in:
- lib/reight/app/sprite/line.rb
Instance Attribute Summary
Attributes inherited from Tool
Attributes inherited from Button
Instance Method Summary collapse
- #canvas_clicked(x, y, button) ⇒ Object
- #canvas_dragged(x, y, button) ⇒ Object
- #canvas_pressed(x, y, button) ⇒ Object
- #draw_line(x, y) ⇒ Object
-
#initialize(app, &block) ⇒ Line
constructor
A new instance of Line.
Methods inherited from Tool
#canvas, #canvas_moved, #canvas_released, #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) ⇒ Line
Returns a new instance of Line.
6 7 8 9 |
# File 'lib/reight/app/sprite/line.rb', line 6 def initialize(app, &block) super app, icon: app.icon(4, 2, 8), &block set_help left: name, right: 'Pick Color' end |
Instance Method Details
#canvas_clicked(x, y, button) ⇒ Object
33 34 35 |
# File 'lib/reight/app/sprite/line.rb', line 33 def canvas_clicked(x, y, ) pick_color x, y if == RIGHT end |
#canvas_dragged(x, y, button) ⇒ Object
27 28 29 30 31 |
# File 'lib/reight/app/sprite/line.rb', line 27 def canvas_dragged(x, y, ) return unless == LEFT app.undo flash: false draw_line x, y end |
#canvas_pressed(x, y, button) ⇒ Object
21 22 23 24 25 |
# File 'lib/reight/app/sprite/line.rb', line 21 def canvas_pressed(x, y, ) return unless == LEFT @x, @y = x, y draw_line x, y end |
#draw_line(x, y) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/reight/app/sprite/line.rb', line 11 def draw_line(x, y) canvas.begin_editing do canvas.paint do |g| g.stroke(*canvas.color) g.stroke_weight 0 g.line @x, @y, x, y end end end |