<commit_before>define (require) ->
	Spine = require 'Spine'
	Raphael = require 'Raphael'

	Marking = require 'controllers/Marking'
	style = require 'style'

	class CreaturePicker extends Spine.Controller
		paper: null
		strayCircles = null
		strayLines = null
		markings: null

		events:
			'click': 'onClick'

		constructor: ->
			super

			@paper = Raphael @el[0], '100%', '100%'
			@markings = []

			@resetStrays()

		resetStrays: =>
			@strayCircles = @paper.set()
			@strayLines = @paper.set()

		onClick: (e) ->
			offset = @el.offset()
			x = e.pageX - offset.left
			y = e.pageY - offset.top

			circle = @paper.circle x, y
			circle.attr style.circle
			@strayCircles.push circle

			# Each pair makes a line.
			if @strayCircles.length is 2
				line = @paper.path Marking::getLineString @strayCircles[0], @strayCircles[1]
			else if @strayCircles.length is 4
				line = @paper.path Marking::getLineString @strayCircles[2], @strayCircles[3]

			if line
				line.toBack()
				line.attr style.line
				@strayLines.push line

			# Each set of four makes a marking.
			if @strayCircles.length is 4
				@markings.push new Marking picker: @, circles: @strayCircles, lines: @strayLines
				@resetStrays()
<commit_msg>Escape key clears stray circles and lines<commit_after>define (require) ->
	Spine = require 'Spine'
	Raphael = require 'Raphael'

	Marking = require 'controllers/Marking'
	style = require 'style'

	class CreaturePicker extends Spine.Controller
		paper: null
		strayCircles = null
		strayLines = null
		markings: null

		events:
			'click': 'onClick'

		constructor: ->
			super

			@paper = Raphael @el[0], '100%', '100%'
			@markings = []

			@resetStrays()

		delegateEvents: =>
			super

			$(document).keydown (e) =>
				if e.keyCode is 27 then @clearStrays()

		clearStrays: =>
			@strayCircles.remove()
			@strayLines.remove()
			@resetStrays()

		resetStrays: =>
			@strayCircles = @paper.set()
			@strayLines = @paper.set()

		onClick: (e) ->
			offset = @el.offset()
			x = e.pageX - offset.left
			y = e.pageY - offset.top

			circle = @paper.circle x, y
			circle.attr style.circle
			@strayCircles.push circle

			# Each pair makes a line.
			if @strayCircles.length is 2
				line = @paper.path Marking::getLineString @strayCircles[0], @strayCircles[1]
			else if @strayCircles.length is 4
				line = @paper.path Marking::getLineString @strayCircles[2], @strayCircles[3]

			if line
				line.toBack()
				line.attr style.line
				@strayLines.push line

			# Each set of four makes a marking.
			if @strayCircles.length is 4
				@markings.push new Marking picker: @, circles: @strayCircles, lines: @strayLines
				@resetStrays()

{'fraction_non_alphanumeric': 0.12293233082706767, 'fraction_numerical': 0.011278195488721804, 'mean_word_length': 3.2507987220447285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '400449', 'n_tokens_mistral': 1140, 'n_tokens_neox': 942, 'n_words': 244}