'use strict'; exports.__esModule = true; exports.default = buildCircle; var _buildLine = require('./buildLine'); var _buildLine2 = _interopRequireDefault(_buildLine); var _const = require('../../../const'); var _utils = require('../../../utils'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Builds a circle to draw * * Ignored from docs since it is not directly exposed. * * @ignore * @private * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw * @param {object} webGLData - an object containing all the webGL-specific information to create this shape */ function buildCircle(graphicsData, webGLData) { // need to convert points to a nice regular data var circleData = graphicsData.shape; var x = circleData.x; var y = circleData.y; var width = void 0; var height = void 0; // TODO - bit hacky?? if (graphicsData.type === _const.SHAPES.CIRC) { width = circleData.radius; height = circleData.radius; } else { width = circleData.width; height = circleData.height; } var totalSegs = Math.floor(30 * Math.sqrt(circleData.radius)) || Math.floor(15 * Math.sqrt(circleData.width + circleData.height)); var seg = Math.PI * 2 / totalSegs; if (graphicsData.fill) { var color = (0, _utils.hex2rgb)(graphicsData.fillColor); var alpha = graphicsData.fillAlpha; var r = color[0] * alpha; var g = color[1] * alpha; var b = color[2] * alpha; var verts = webGLData.points; var indices = webGLData.indices; var vecPos = verts.length / 6; indices.push(vecPos); for (var i = 0; i < totalSegs + 1; i++) { verts.push(x, y, r, g, b, alpha); verts.push(x + Math.sin(seg * i) * width, y + Math.cos(seg * i) * height, r, g, b, alpha); indices.push(vecPos++, vecPos++); } indices.push(vecPos - 1); } if (graphicsData.lineWidth) { var tempPoints = graphicsData.points; graphicsData.points = []; for (var _i = 0; _i < totalSegs + 1; _i++) { graphicsData.points.push(x + Math.sin(seg * _i) * width, y + Math.cos(seg * _i) * height); } (0, _buildLine2.default)(graphicsData, webGLData); graphicsData.points = tempPoints; } } //# sourceMappingURL=buildCircle.js.map