Shoes.app do
	def reset
		clear
		
		@is_drawing = false
		@tools = [:line, :arrow, :star, :rect, :oval]
		@current_tool = :line
		
		stack do
			background black, :height => 40
			flow :margin => 10 do 
				caption "Sketchers", :stroke => white, :margin_right => 25
				@tools.each do |tool|
					button(tool.to_s) { @current_tool = tool }
				end
				button("stroke color") do
					new_color = ask_color("Pick a Color")
					stroke new_color
					fill new_color
				end
				button("clear") do
					reset
				end
			end
		end
	end
	
	reset
	
	click do
		if @is_drawing == false
			start_drawing
			@is_drawing = true
		end
	end
	
	release do
		if @is_drawing == true
			motion nil
			@is_drawing = false
		end
	end
	
	def start_drawing
		x, y = nil, nil
		motion do |new_x, new_y|
			if x and y and (x != new_x or y != new_y)
				append do
					case @current_tool
						when :line
							line x, y, new_x, new_y
						when :arrow
							arrow x, y, 10
						when :star
							star x, y, 5, 10, 50
						when :rect
							rect x, y, 10, 10
						when :oval
							oval x, y, 10, 10
					end
				end
			end
			x, y = new_x, new_y
		end
	end
end
