lib/rabbit/graffiti/processor.rb in rabbit-2.1.3 vs lib/rabbit/graffiti/processor.rb in rabbit-2.1.4

- old
+ new

@@ -18,32 +18,32 @@ end def have_graffiti? not @segments.empty? end - + def can_undo? not @undo_stack.empty? end - + def button_press(x, y, width, height) @pressed = true @undo_index = nil @segments << [[x.to_f / width, y.to_f / height]] end - + def button_release(x, y, width, height) @pressed = false @undo_stack << [:push] end - + def button_motion(x, y, width, height) if @pressed @segments.last << [x.to_f / width, y.to_f / height] end end - + def draw_last_segment(renderer) points = @segments.last if points.size >= 2 width = renderer.width height = renderer.height @@ -53,11 +53,11 @@ renderer.draw_line(prev_x * width, prev_y * height, x * width, y * height, @color, {:line_width => @line_width}) end end - + def draw_all_segment(renderer) return if @segments.empty? args = [@color, {:line_width => @line_width, :opened => true}] width = renderer.width height = renderer.height @@ -66,15 +66,15 @@ [x * width, y * height] end renderer.draw_lines(converted_points, *args) end end - + def dragging? @pressed end - + def clear @pressed = false @segments = [] @undo_stack = [] @undo_index = nil @@ -102,10 +102,10 @@ @undo_stack << [:pop, @segments.pop] when :pop @segments << segment @undo_stack << [:push] end - + if @undo_index > 0 @undo_index -= 1 else @undo_index = nil end