<commit_before>//
//  UTVertexLayer.swift
//  KiwiControls
//
//  Created by <NAME> on 2016/10/09.
//  Copyright © 2016年 Steel Wheels Project. All rights reserved.
//

import Foundation
import KiwiControls
import KiwiGraphics

private class UTVertexDrawer: KCGraphicsLayer
{
	private var mEclipse:	KGEclipse
	private var mGradient:	CGGradient

	public init(bounds b: CGRect, color c: CGColor){
		let center = b.center
		let radius = min(b.size.width, b.size.height)/2.0
		mEclipse  = KGEclipse(center: center, innerRadius: radius*0.4, outerRadius: radius)
		mGradient = KGGradientTable.sharedGradientTable.gradient(forColor: c)
		super.init(bounds: b)
	}

	public override func drawContent(context ctxt:CGContext, bounds bnd:CGRect, dirtyRect drect:CGRect){
		if bnd.intersects(drect) {
			ctxt.setStrokeColor(KGColorTable.white.cgColor)
			ctxt.draw(eclipse: mEclipse, withGradient: mGradient)
		}
	}
}

#if true
public func UTVertexLayer(bounds b: CGRect) -> KCRepetitiveDrawer
{
	let glyph = KGGlyph(bounds: b)

	let elmradius = glyph.elementRadius
	let elmbounds = CGRect(origin: CGPoint.zero, size: CGSize(width: elmradius, height: elmradius))

	let drawer = UTVertexDrawer(bounds: elmbounds, color: KGColorTable.gold.cgColor)
	let layer  = KCRepetitiveDrawer(bounds: b, elementDrawer: drawer)

	let halfradius = elmradius / 2.0
	for vertex in glyph.vertices {
		let pt = CGPoint(x: vertex.x - halfradius, y: vertex.y - halfradius)
		layer.add(location: pt)
	}

	return layer
}
#else
public func UTVertexLayer(bounds b: CGRect) -> KCGraphicsLayer
{
	return UTVertexDrawer(bounds: b, color: KGColorTable.gold.cgColor)
}
#endif


<commit_msg>unit-test : Update parameter to draw glyph vertex<commit_after>//
//  UTVertexLayer.swift
//  KiwiControls
//
//  Created by <NAME> on 2016/10/09.
//  Copyright © 2016年 Steel Wheels Project. All rights reserved.
//

import Foundation
import KiwiControls
import KiwiGraphics

private class UTVertexDrawer: KCGraphicsLayer
{
	private var mEclipse:	KGEclipse
	private var mGradient:	CGGradient

	public init(bounds b: CGRect, color c: CGColor){
		let center = b.center
		let radius = min(b.size.width, b.size.height)/2.0
		mEclipse  = KGEclipse(center: center, innerRadius: radius*0.5, outerRadius: radius)
		mGradient = KGGradientTable.sharedGradientTable.gradient(forColor: c)
		super.init(bounds: b)
	}

	public override func drawContent(context ctxt:CGContext, bounds bnd:CGRect, dirtyRect drect:CGRect){
		if bnd.intersects(drect) {
			ctxt.setStrokeColor(KGColorTable.white.cgColor)
			ctxt.draw(eclipse: mEclipse, withGradient: mGradient)
		}
	}
}

#if true
public func UTVertexLayer(bounds b: CGRect) -> KCRepetitiveDrawer
{
	let glyph = KGGlyph(bounds: b)

	let elmradius = glyph.elementRadius
	let elmbounds = CGRect(origin: CGPoint.zero, size: CGSize(width: elmradius, height: elmradius))

	let drawer = UTVertexDrawer(bounds: elmbounds, color: KGColorTable.white.cgColor)
	let layer  = KCRepetitiveDrawer(bounds: b, elementDrawer: drawer)

	let halfradius = elmradius / 2.0
	for vertex in glyph.vertices {
		let pt = CGPoint(x: vertex.x - halfradius, y: vertex.y - halfradius)
		layer.add(location: pt)
	}

	return layer
}
#else
public func UTVertexLayer(bounds b: CGRect) -> KCGraphicsLayer
{
	return UTVertexDrawer(bounds: b, color: KGColorTable.gold.cgColor)
}
#endif


{'fraction_non_alphanumeric': 0.10342754058929646, 'fraction_numerical': 0.010823812387251955, 'mean_word_length': 4.677474402730375, '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': '3741530', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1158, 'n_words': 298}