<commit_before>//
//  Sketch.swift
//  DripTimer
//
//  Created by <NAME> on 2016/01/24.
//  Copyright © 2016年 masaichi. All rights reserved.
//

import Foundation
import UIKit
import QuartzCore

class Sketch {
    class Canvas {
        let context: CGContextRef
        init(context: CGContextRef) {
            self.context = context
        }
        
        func fill(color: UIColor?) {
            if let color = color {
                CGContextSetFillColorWithColor(context, color.CGColor)
            }
        }
        
        func stroke(color: UIColor?) {
            if let color = color {
                CGContextSetStrokeColorWithColor(context, color.CGColor)
            }
        }
        
        func circle(r: Float) {
            let radius = CGFloat(r)
            CGContextAddArc(context, radius, radius, radius, 0, CGFloat(2 * M_PI), 0)
            CGContextFillPath(context)
            CGContextStrokePath(context)
        }
    }
    
    static func draw(size: CGSize, f:(Canvas -> Void) ) -> UIImage? {
        UIGraphicsBeginImageContext(size)
        if let context = UIGraphicsGetCurrentContext() {
            let canvas = Canvas(context: context)<commit_msg>export Sketch and Canvas class<commit_after>//
//  Sketch.swift
//  DripTimer
//
//  Created by <NAME> on 2016/01/24.
//  Copyright © 2016年 masaichi. All rights reserved.
//

import Foundation
import UIKit
import QuartzCore

public class Sketch {
    public class Canvas {
        public let context: CGContextRef
        public init(context: CGContextRef) {
            self.context = context
        }
        
        public func fill(color: UIColor?) {
            if let color = color {
                CGContextSetFillColorWithColor(context, color.CGColor)
            }
        }
        
        public func stroke(color: UIColor?) {
            if let color = color {
                CGContextSetStrokeColorWithColor(context, color.CGColor)
            }
        }
        
        public func circle(r: Float) {
            let radius = CGFloat(r)
            CGContextAddArc(context, radius, radius, radius, 0, CGFloat(2 * M_PI), 0)
            CGContextFillPath(context)
            CGContextStrokePath(context)
        }
    }
    
    public static func draw(size: CGSize, f:(Canvas -> Void) ) -> UIImage? {
        UIGraphicsBeginImageContext(size)
        if let context = UIGraphicsGetCurrentContext() {
            let canvas = Canvas(context: context)
{'fraction_non_alphanumeric': 0.0883664369679773, 'fraction_numerical': 0.012160518848804215, 'mean_word_length': 1.833524684270953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '204106', 'n_tokens_mistral': 747, 'n_tokens_neox': 697, 'n_words': 175}