<commit_before>//
//  TOEView.swift
//  TokyoOlympicEmblem
//
//  Created by <NAME> on 2015/08/06.
//  Copyright (c) 2015年 <NAME>. All rights reserved.
//

import UIKit

class TOEView: UIView {

    var l: CGFloat!
    var r: CGFloat!
    
    override func awakeFromNib() {
        super.awakeFromNib()

        l = frame.size.width / 3
        r = sqrt(1.5 * 1.5 + 0.5 * 0.5) * l
    }
    
    override func drawRect(rect: CGRect) {
        
        self.drawYellowArc()
        self.drawBlackRect()
        self.drawRedOval()
        self.drawGreyArc()
    }

    
    // =========================================================================
    // MARK: - Private
    
    private func drawYellowArc() {
        let path = UIBezierPath(
            arcCenter: CGPointMake(l * 1.5, l * 1.5),
            radius: r,
            startAngle: CGFloat(-M_PI_2),
            endAngle: CGFloat(-M_PI),
            clockwise: false)
        path.addLineToPoint(CGPointZero)
        
        UIColor(red: 1.0, green: 0.84, blue: 0.0, alpha: 1.0).setFill()
        path.fill()
    }

    private func drawBlackRect() {
        
        let rect = CGRectMake(l, 0, l, l * 3)
        let path = UIBezierPath(rect: rect)
        
        UIColor.blackColor().setFill()
        path.fill()
    }

    private func drawRedOval() {

        let rect = CGRectMake(l * 2, 0, l, l)
        let path = UIBezierPath(ovalInRect: rect)
        
        UIColor.redColor().setFill()
        path.fill()
    }
    
    private func drawGreyArc() {
        
        let path = UIBezierPath(
            arcCenter: CGPointMake(l * 1.5, l * 1.5),
            radius: r,
            startAngle: 0,
            endAngle: CGFloat(M_PI_2),
            clockwise: true)
        path.addLineToPoint(CGPointMake(l * 3, l * 3))
        
        UIColor(white: 0.5, alpha: 1.0).setFill()
        path.fill()<commit_msg>Add Paralympic mode.<commit_after>//
//  TOEView.swift
//  TokyoOlympicEmblem
//
//  Created by <NAME> on 2015/08/06.
//  Copyright (c) 2015年 <NAME>. All rights reserved.
//

import UIKit

class TOEView: UIView {

    enum DrawEmblem: Int {
        case Olympic
        case Paralympic
    }
    
    var l: CGFloat!
    var r: CGFloat!
    var drawEmblem = DrawEmblem.Paralympic
    
    override func awakeFromNib() {
        super.awakeFromNib()

        l = frame.size.width / 3
        r = sqrt(1.5 * 1.5 + 0.5 * 0.5) * l
        
        if drawEmblem == DrawEmblem.Paralympic {
            backgroundColor = UIColor.blackColor()
        }
    }
    
    override func drawRect(rect: CGRect) {
        
        self.drawYellowArc()
        self.drawBlackRect()
        self.drawRedOval()
        self.drawGreyArc()
    }

    
    // =========================================================================
    // MARK: - Private
    
    private func drawYellowArc() {
        let path = UIBezierPath(
            arcCenter: CGPointMake(l * 1.5, l * 1.5),
            radius: r,
            startAngle: CGFloat(-M_PI_2),
            endAngle: CGFloat(-M_PI),
            clockwise: false)
        path.addLineToPoint(CGPointZero)
        
        UIColor(red: 1.0, green: 0.84, blue: 0.0, alpha: 1.0).setFill()
        path.fill()
    }

    private func drawBlackRect() {
        
        let rect = CGRectMake(l, 0, l, l * 3)
        let path = UIBezierPath(rect: rect)
        
        switch drawEmblem {
        case .Olympic:
            UIColor.blackColor().setFill()
        case .Paralympic:
            UIColor.whiteColor().setFill()
        }
        path.fill()
    }

    private func drawRedOval() {

        let rect = CGRectMake(l * 2, 0, l, l)
        let path = UIBezierPath(ovalInRect: rect)
        
        UIColor.redColor().setFill()
        path.fill()
    }
    
    private func drawGreyArc() {
        
        let path = UIBezierPath(
            arcCenter: CGPointMake(l * 1.5, l * 1.5),
            radius: r,
            startAngle: 0,
            endAngle: CGFloat(M_PI_2),
            clockwise: true)
        path.addLineToPoint(CGPointMake(l * 3, l * 3))
        
        UIColor(white: 0.5, alpha: 1.0).setFill()
        path.fill()
{'fraction_non_alphanumeric': 0.14906385021603458, 'fraction_numerical': 0.024483917426788286, 'mean_word_length': 1.654140127388535, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2953430', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1362, 'n_words': 299}