 			alert textStatus + " : " + error
 	)
 # }}}
-# Canvas art {{{
+# Canvas art and Button UI {{{
 # Low-level things
 drawCircle = (p, color = "blue", r = 10) ->
 	CONTEXT.beginPath()

		tempAddClass "#check_button", "button_red"
		diagram.mistakes += 1

onDoneButtonClick = (e) ->
	if diagram.unfound_tuples.length == 0
		startNextDiagram
		tempAddClass "#done_button", "button_green"
	else
		tempAddClass "#done_button", "button_red"
		diagram.mistakes += 1


startNextDiagram = () ->
	console.log("Next diagram")

# }}}
# Start Game {{{
startGame = () ->
	CANVAS = $("<canvas></canvas>")
	CANVAS.attr "height", CANVAS_HEIGHT

	markAllActive()

onDiagramClick = (e) ->
	o = new Point("", e.pageX-this.offsetLeft, e.pageY-this.offsetTop)
		# where user clicked
	# Grab the closest point to the click
	diagram.flat_points.sort( (p,q) -> dist(o,p)-dist(o,q) )
	p = diagram.flat_points[0]
