<commit_before>//
//  ViewController.swift
//  Example
//
//  Created by <NAME> on 4/24/16.
//  Copyright © 2016 Sticks. All rights reserved.
//

import UIKit
import FingerPaint

class ViewController: UIViewController {
	
//	var path: UIBezierPath?
	var shapeLayer: CAShapeLayer?
	let colors: [UIColor] = [.purpleColor(), .orangeColor(), .blueColor(), .greenColor(), .redColor()]
	var colorIndex = 0
	var points: [CGPoint] = []
	
	override func viewDidLoad() {
		super.viewDidLoad()
		let paintGestureRecognizer = PaintGestureRecognizer(target: self, action: #selector(ViewController.handlePaint(_:)))
		view.addGestureRecognizer(paintGestureRecognizer)
//		let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleTap(_:)))
//		view.addGestureRecognizer(tapGestureRecognizer)
//		tapGestureRecognizer.cancelsTouchesInView = true
	}
	
	func handleTap(tapGestureRecognizer: UITapGestureRecognizer) {
		print("tap")
	}
	
	func handlePaint(paintGestureRecognizer: PaintGestureRecognizer) {
		switch paintGestureRecognizer.state {
		case .Began:
			print("vc touch began")
			let path = UIBezierPath()
			points = []
			switch paintGestureRecognizer.anchorState {
			case .None:
				print("unreachable")
			case .Single(let touch):
				points.append(touch.locationInView(view))
			case .Double(let first, let second):
//				path.moveToPoint(first.locationInView(view))
//				path.moveToPoint(second.locationInView(view))
//				path.addLineToPoint(second.locationInView(view))
				points.append(second.locationInView(view))
			}
			path.moveToPoint(points[0])
			for point in points {
				path.addLineToPoint(point)
			}
			let shapeLayer = CAShapeLayer()
			shapeLayer.path = path.CGPath
			shapeLayer.strokeColor = colors[colorIndex].CGColor
			if 0..<colors.count-1 ~= colorIndex {
				colorIndex += 1
			} else {
				colorIndex = 0
			}
			shapeLayer.fillColor = UIColor.clearColor().CGColor
			shapeLayer.lineWidth = 8
			self.shapeLayer = shapeLayer
			view.layer.addSublayer(shapeLayer)
		case .Changed:
			switch paintGestureRecognizer.anchorState {
			case .None:
				print("unreachable")
			case .Single(let touch):
				points.append(touch.locationInView(view))
			case .Double(let first, let second):
//				path?.addLineToPoint(first.locationInView(view))
				points.removeLast()
				if points.count > 0 {
					points.removeLast()
				}
				points.append(first.locationInView(view))
				points.append(second.locationInView(view))
			}
			let path = UIBezierPath()
			path.moveToPoint(points[0])
			for point in points {
				path.addLineToPoint(point)
			}
			shapeLayer?.path = path.CGPath
		default:
			break
		}
	}
}<commit_msg>layers<commit_after>//
//  ViewController.swift
//  Example
//
//  Created by <NAME> on 4/24/16.
//  Copyright © 2016 Sticks. All rights reserved.
//

import UIKit
import FingerPaint

class ViewController: UIViewController {
	
	var shapeLayers: [CAShapeLayer] = []
	let colors: [UIColor] = [.purpleColor(), .orangeColor(), .blueColor(), .greenColor(), .redColor()]
	var colorIndex = 0
	var points: [CGPoint] = []
	
	override func viewDidLoad() {
		super.viewDidLoad()
		let paintGestureRecognizer = PaintGestureRecognizer(target: self, action: #selector(ViewController.handlePaint(_:)))
		view.addGestureRecognizer(paintGestureRecognizer)
//		let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleTap(_:)))
//		view.addGestureRecognizer(tapGestureRecognizer)
//		tapGestureRecognizer.cancelsTouchesInView = true
	}
	
	func handleTap(tapGestureRecognizer: UITapGestureRecognizer) {
		print("tap")
	}
	
	func handlePaint(paintGestureRecognizer: PaintGestureRecognizer) {
		switch paintGestureRecognizer.state {
		case .Began:
			print("vc touch began")
			let path = UIBezierPath()
			points = []
			switch paintGestureRecognizer.anchorState {
			case .None:
				print("unreachable")
			case .Single(let touch):
				points.append(touch.locationInView(view))
			case .Double(_, let second):
				points.append(second.locationInView(view))
			}
			path.moveToPoint(points[0])
			for point in points {
				path.addLineToPoint(point)
			}
			let shapeLayer = CAShapeLayer()
			shapeLayer.path = path.CGPath
			shapeLayer.strokeColor = colors[colorIndex].CGColor
			if 0..<colors.count-1 ~= colorIndex {
				colorIndex += 1
			} else {
				colorIndex = 0
			}
			shapeLayer.fillColor = UIColor.clearColor().CGColor
			shapeLayer.lineWidth = 8
			shapeLayers.append(shapeLayer)
			view.layer.addSublayer(shapeLayer)
		case .Changed:
			switch paintGestureRecognizer.anchorState {
			case .None:
				print("unreachable")
			case .Single(let touch):
				points.append(touch.locationInView(view))
			case .Double(let first, let second):
//				path?.addLineToPoint(first.locationInView(view))
				points.removeLast()
				if points.count > 0 {
					points.removeLast()
				}
				points.append(first.locationInView(view))
				points.append(second.locationInView(view))
			}
			let path = UIBezierPath()
			path.moveToPoint(points[0])
			for point in points {
				path.addLineToPoint(point)
			}
			shapeLayers.last?.path = path.CGPath
			
		case .Ended:
			for shape in shapeLayers {
				shape.opacity -= 0.1
				if shape.opacity <= 0 {
					shape.removeFromSuperlayer()
				}
			}
		default:
			break
		}
	}
}
{'fraction_non_alphanumeric': 0.1194141945174615, 'fraction_numerical': 0.00732256853173113, 'mean_word_length': 3.8737419945105214, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '6859175', 'n_tokens_mistral': 2146, 'n_tokens_neox': 1741, 'n_words': 330}