// создаем изображение смайлик // рисуем его относительно точки (0, 0) function drawSmile(svg) { let smile = svg.append("g") .style("stroke", "brown") .style("stroke-width", 0) .style("fill", "brown"); for (let t = 0; t <= Math.PI * 6; t += .8) { let cords = { x: 50 / 3 * (1 - (t / (Math.PI * 6))) * -Math.sin(t), y: 50 / 3 * (1 - (t / (Math.PI * 6))) * Math.cos(t) } smile.append("circle") .attr("cx", cords["x"]) .attr("cy", cords["y"]) .attr("r", (1 - (t / (Math.PI * 6)))) .style("fill", "red"); } for (let t = .4; t <= Math.PI * 6; t += .8) { let cords = { x: 50 / 3 * (1 - (t / (Math.PI * 6))) * -Math.sin(t), y: 50 / 3 * (1 - (t / (Math.PI * 6))) *Math.cos(t) } smile.append("circle") .attr("cx", cords["x"]) .attr("cy", cords["y"]) .attr("r", (1 - (t / (Math.PI * 6)))) .style("fill", "green"); } return smile }