Cutter SVG

오버런에 쓰이는 meiro-cutter.svg를 만들기 위한 스크립트이다.

const CENTER_X = 256;
const CENTER_Y = 256;
const RADIUS = 128;
const CUTTER_SIZE = 32;
const EDGE_SIZE = 32;
const EDGE_ANGLE = 45;

var positions = {};
for(var _angle = 0; _angle <= 180; _angle += 36){
	positions[_angle] = {};

	var angle = _angle * Math.PI / 180;
	var points = positions[_angle];

	//start point
	points.start = {
		x: Math.round(CENTER_X - (Math.cos(angle) * RADIUS)),
		y: Math.round(CENTER_Y - (Math.sin(angle) * RADIUS))
	};
	
	//Edge Start point
	points.edgeStart = {
		x: Math.round(CENTER_X - (Math.cos(angle) * (RADIUS + CUTTER_SIZE))),
		y: Math.round(CENTER_Y - (Math.sin(angle) * (RADIUS + CUTTER_SIZE)))
	};
	
	points.edgeEnd = {
		x: Math.round(points.edgeStart.x - (Math.cos((_angle + EDGE_ANGLE) * Math.PI / 180) * EDGE_SIZE * Math.sqrt(2))),
		y: Math.round(points.edgeStart.y - (Math.sin((_angle + EDGE_ANGLE) * Math.PI / 180) * EDGE_SIZE * Math.sqrt(2)))
	};
}

Object.values = (v) => Object.keys(v).map((k) => v[k]);

Object.values(positions).reduce((prev, curr) => {
	return `${prev + '\n'}<path d="M ${curr.start.x},${curr.start.y} L ${curr.edgeStart.x},${curr.edgeStart.y} L ${curr.edgeEnd.x},${curr.edgeEnd.y} L ${CENTER_X},${CENTER_Y} Z"/>`;
}, '<path d="M 128,256 A 128,128 0 0,1 384,256"/>');