UNPKG

amos-tool

Version:

amos ui tool

18 lines (16 loc) 666 B
"use strict"; var drawPolygon = function(t, o) { var a = o && o.x || 0, l = o && o.y || 0, e = o && o.num || 3, r = o && o.r || 100, i = o && o.width || 5, n = o && o.strokeStyle, h = o && o.fillStyle; t.beginPath(); var s = a + r * Math.cos(2 * Math.PI * 0 / e), P = l + r * Math.sin(2 * Math.PI * 0 / e); t.moveTo(s, P); for (var y = 1; y <= e; y++) { var M = a + r * Math.cos(2 * Math.PI * y / e), d = l + r * Math.sin(2 * Math.PI * y / e); t.lineTo(M, d); } t.closePath(), n && (t.strokeStyle = n, t.lineWidth = i, t.lineJoin = "round", t.stroke()), h && (t.fillStyle = h, t.fill()); }; module.exports = { drawPolygon: drawPolygon };