<commit_before>//
//  UIImageExtensions.swift
//  Pods
//
//  Created by <NAME> on 15/12/6.
//
//

import UIKit

public enum BorderPosition{
  case inside
  case center
  case outside
}

public enum CornerStyle{
  case oval
  case semiCircle
  case radius(CGFloat)
  case none
}

public extension BanxiExtensions where Base:UIImage{

  public static func roundImage(fillColor:UIColor? = nil,
                                size:CGSize=CGSize(width: 32, height: 32),
                                cornerStyle:CornerStyle = .radius(4),
                                borderPostion:BorderPosition = .inside,
                                borderWidth:CGFloat = 0,
                                borderColor:UIColor? = nil
    ) -> UIImage{
    // 为 border 腾出点地方
    // size 参数定义的是画而大小, inset 之后的才是绘制的大小.
    let inset:CGFloat
    if borderWidth > 0 {
      switch borderPostion {
      case .inside:
        inset = borderWidth
      case .outside:
        inset = 0
      case .center:
        inset = borderWidth * 0.5
      }
    }else{
      inset = 0
    }
    let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
    let pathRect = rect.insetBy(dx: inset, dy: inset)
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    let ctx = UIGraphicsGetCurrentContext()
    UIColor.clear.setFill()
    ctx?.fill(rect)
    fillColor?.setFill()
    borderColor?.setStroke()
    let path:UIBezierPath
    switch cornerStyle {
    case .oval:
        path = UIBezierPath(ovalIn: pathRect)
    case .semiCircle:
       let radius = pathRect.height * 0.5
        path = UIBezierPath(roundedRect: pathRect, cornerRadius: radius)
    case .radius(let rd):
        path = UIBezierPath(roundedRect: pathRect, cornerRadius: rd)
    case .none:
        path = UIBezierPath(rect: pathRect)
    }<commit_msg>fix typ<commit_after>//
//  UIImageExtensions.swift
//  Pods
//
//  Created by <NAME> on 15/12/6.
//
//

import UIKit

public enum BorderPosition{
  case inside
  case center
  case outside
}

public enum CornerStyle{
  case oval
  case semiCircle
  case radius(CGFloat)
  case none
}

public extension BanxiExtensions where Base:UIImage{

  public static func roundImage(fillColor:UIColor? = nil,
                                size:CGSize=CGSize(width: 32, height: 32),
                                cornerStyle:CornerStyle = .radius(4),
                                borderPosition:BorderPosition = .inside,
                                borderWidth:CGFloat = 0,
                                borderColor:UIColor? = nil
    ) -> UIImage{
    // 为 border 腾出点地方
    // size 参数定义的是画而大小, inset 之后的才是绘制的大小.
    let inset:CGFloat
    if borderWidth > 0 {
      switch borderPosition {
      case .inside:
        inset = borderWidth
      case .outside:
        inset = 0
      case .center:
        inset = borderWidth * 0.5
      }
    }else{
      inset = 0
    }
    let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
    let pathRect = rect.insetBy(dx: inset, dy: inset)
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    let ctx = UIGraphicsGetCurrentContext()
    UIColor.clear.setFill()
    ctx?.fill(rect)
    fillColor?.setFill()
    borderColor?.setStroke()
    let path:UIBezierPath
    switch cornerStyle {
    case .oval:
        path = UIBezierPath(ovalIn: pathRect)
    case .semiCircle:
       let radius = pathRect.height * 0.5
        path = UIBezierPath(roundedRect: pathRect, cornerRadius: radius)
    case .radius(let rd):
        path = UIBezierPath(roundedRect: pathRect, cornerRadius: rd)
    case .none:
        path = UIBezierPath(rect: pathRect)
    }
{'fraction_non_alphanumeric': 0.09295929592959296, 'fraction_numerical': 0.01155115511551155, 'mean_word_length': 2.056302521008403, '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': '2117028', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1148, 'n_words': 285}