<commit_before>//
//  RootBorderView.swift
//  Squizit
//
//  Created by <NAME> on 9/16/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit

class RootBorderView : UIView {

	var topLeftColor:UIColor = UIColor(red: 0.49, green: 1, blue: 0, alpha: 1)
	var bottomRightColor:UIColor = UIColor(red: 1, green: 0, blue: 0.71, alpha: 1)

	var borderSize:Int = 32 {
		didSet {
			setNeedsDisplay()
		}
	}

	override func drawRect(rect: CGRect) {

		var context = UIGraphicsGetCurrentContext()
		CGContextSaveGState(context)
		CGContextTranslateCTM(context, 0.5, 0.5)

		let bounds = self.bounds
		let borderSize = CGFloat(self.borderSize)

		func plot( x:Int, y:Int ) -> CGPoint {
			let px = x >= 0 ? CGFloat(x) * borderSize : bounds.width + CGFloat(x)*borderSize
			let py = y >= 0 ? CGFloat(y) * borderSize : bounds.height + CGFloat(y)*borderSize
			return CGPoint( x: px, y: py )
		}

		func m( p:CGPoint ) {
			CGContextMoveToPoint(context, p.x, p.y)
		}

		func l( p:CGPoint ) {
			CGContextAddLineToPoint(context, p.x, p.y)
		}

		m(plot( 1, 1))
		l(plot( 2, 1))
		l(plot( 2,-1))
		l(plot( 1,-1))
		l(plot( 1,-2))
		l(plot(-1,-2))
		l(plot(-1,-1))
		l(plot(-2,-1))
		l(plot(-2, 1))
		l(plot(-1, 1))
		l(plot(-1, 2))
		l(plot( 1, 2))
		CGContextClosePath(context)

		m(plot( 3, 1))
		l(plot(-3, 1))
		l(plot(-3, 3))
		l(plot(-1, 3))
		l(plot(-1,-3))
		l(plot(-3,-3))
		l(plot(-3,-1))
		l(plot( 3,-1))
		l(plot( 3,-3))
		l(plot( 1,-3))
		l(plot( 1, 3))
		l(plot( 3, 3))
		CGContextClosePath(context)

		CGContextSetLineWidth(context, 1)
		CGContextReplacePathWithStrokedPath(context)
		CGContextClip(context)

		let colorSpace = CGColorSpaceCreateDeviceRGB()
		let gradient = CGGradientCreateWithColors(colorSpace, [topLeftColor.CGColor,bottomRightColor.CGColor], [0.0,1.0])
		let topLeft = plot(1,1)
		let bottomRight = plot(-1,-1)
		CGContextDrawLinearGradient(context, gradient, topLeft, bottomRight, CGGradientDrawingOptions(0))

		CGContextRestoreGState(context)
	}

	override func awakeFromNib() {
		contentMode = UIViewContentMode.Redraw
		opaque = false
		backgroundColor = UIColor.clearColor()
	}

}<commit_msg>"Fix" a weird retina rendering error in the root border view<commit_after>//
//  RootBorderView.swift
//  Squizit
//
//  Created by <NAME> on 9/16/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import UIKit

class RootBorderView : UIView {

	var topLeftColor:UIColor = UIColor(red: 0.49, green: 1, blue: 0, alpha: 1)
	var bottomRightColor:UIColor = UIColor(red: 1, green: 0, blue: 0.71, alpha: 1)

	var borderSize:Int = 32 {
		didSet {
			setNeedsDisplay()
		}
	}

	override func drawRect(rect: CGRect) {

		var context = UIGraphicsGetCurrentContext()
		CGContextSaveGState(context)
		CGContextTranslateCTM(context, 0.5, 0.5)

		let bounds = self.bounds
		let borderSize = CGFloat(self.borderSize)

		func plot( x:Int, y:Int ) -> CGPoint {
			let px = x >= 0 ? CGFloat(x) * borderSize : bounds.width + CGFloat(x)*borderSize
			let py = y >= 0 ? CGFloat(y) * borderSize : bounds.height + CGFloat(y)*borderSize
			return CGPoint( x: px, y: py )
		}

		func m( p:CGPoint ) {
			CGContextMoveToPoint(context, p.x, p.y)
		}

		func l( p:CGPoint ) {
			CGContextAddLineToPoint(context, p.x, p.y)
		}

		m(plot( 1, 1))
		l(plot( 2, 1))
		l(plot( 2,-1))
		l(plot( 1,-1))
		l(plot( 1,-2))
		l(plot(-1,-2))
		l(plot(-1,-1))
		l(plot(-2,-1))
		l(plot(-2, 1))
		l(plot(-1, 1))
		l(plot(-1, 2))
		l(plot( 1, 2))
		CGContextClosePath(context)

		m(plot( 3, 1))
		l(plot(-3, 1))
		l(plot(-3, 3))
		l(plot(-1, 3))
		l(plot(-1,-3))
		l(plot(-3,-3))
		l(plot(-3,-1))
		l(plot( 3,-1))
		l(plot( 3,-3))
		l(plot( 1,-3))
		l(plot( 1, 3))
		l(plot( 3, 3))
		CGContextClosePath(context)

		CGContextSetLineWidth(context, 1)
		CGContextSetLineCap(context, kCGLineCapSquare)

		CGContextReplacePathWithStrokedPath(context)
		CGContextClip(context)

		let colorSpace = CGColorSpaceCreateDeviceRGB()
		let gradient = CGGradientCreateWithColors(colorSpace, [topLeftColor.CGColor,bottomRightColor.CGColor], [0.0,1.0])
		let topLeft = plot(1,1)
		let bottomRight = plot(-1,-1)
		CGContextDrawLinearGradient(context, gradient, topLeft, bottomRight, CGGradientDrawingOptions(0))

		// fix a rendering error on retina where the top left point of the path isn't drawn
		if UIScreen.mainScreen().scale > 1 {
			let pointRect = CGRect(center: plot(1,1), radius: 0.5)
			CGContextSetFillColorWithColor(context, topLeftColor.CGColor)
			CGContextFillRect(context, pointRect)
		}

		CGContextRestoreGState(context)
	}

	override func awakeFromNib() {
		contentMode = UIViewContentMode.Redraw
		opaque = false
		backgroundColor = UIColor.clearColor()
	}

}
{'fraction_non_alphanumeric': 0.15770302121277052, 'fraction_numerical': 0.03835440325691022, 'mean_word_length': 3.802469135802469, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2344054', 'n_tokens_mistral': 2114, 'n_tokens_neox': 1835, 'n_words': 409}