# File lib/rabbit/graffiti/processor.rb, line 24 def can_undo? not @undo_stack.empty? end
# File lib/rabbit/graffiti/processor.rb, line 83 def change_color(&block) dialog = Graffiti::ConfigDialog.new(@color, @line_width) dialog.run do |color, line_width| @color = color if color @line_width = line_width if line_width block.call end end
# File lib/rabbit/graffiti/processor.rb, line 76 def clear @pressed = false @segments = [] @undo_stack = [] @undo_index = nil end
# File lib/rabbit/graffiti/processor.rb, line 92 def clear_config @color = @default_color @line_width = @default_line_width end
# File lib/rabbit/graffiti/processor.rb, line 72 def dragging? @pressed end
# File lib/rabbit/graffiti/processor.rb, line 59 def draw_all_segment(renderer) return if @segments.empty? args = [@color, {:line_width => @line_width, :opened => true}] width = renderer.width height = renderer.height @segments.each do |points| converted_points = points.collect do |x, y| [x * width, y * height] end renderer.draw_lines(converted_points, *args) end end
# File lib/rabbit/graffiti/processor.rb, line 45 def draw_last_segment(renderer) points = @segments.last if points.size >= 2 width = renderer.width height = renderer.height prev, current = points[-2..-1] prev_x, prev_y = prev x, y = current renderer.draw_line(prev_x * width, prev_y * height, x * width, y * height, @color, {:line_width => @line_width}) end end
# File lib/rabbit/graffiti/processor.rb, line 20 def have_graffiti? not @segments.empty? end
# File lib/rabbit/graffiti/processor.rb, line 97 def undo @undo_index ||= @undo_stack.size - 1 command, segment = @undo_stack[@undo_index] case command when :push @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 end
Generated with the Darkfish Rdoc Generator 2.