Files
uni-web-site/labs/lab2/JavaScript/image.js
2026-03-12 23:02:05 +10:00

33 lines
942 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// создаем изображение смайлик
// рисуем его относительно точки (0, 0)
function drawSmile(svg) {
let smile = svg.append("g")
.style("stroke", "brown")
.style("stroke-width", 2)
.style("fill", "brown");
//лицо
smile.append("circle")
.attr("cx", 0)
.attr("cy", 0)
.attr("r", 50)
.style("fill", "yellow");
//левый глаз
smile.append("circle")
.attr("cx", -20)
.attr("cy", -10)
.attr("r", 5);
//правый глаз
smile.append("circle")
.attr("cx", 20)
.attr("cy", -10)
.attr("r", 5);
// улыбка
let arc = d3.arc()
.innerRadius(35)
.outerRadius(35);
smile.append("path")
.attr("d", arc({startAngle: Math.PI /3 * 2, endAngle: Math.PI/3 * 4}))
.style("stroke", "brown")
return smile
}