adding svg to site

This commit is contained in:
2026-03-13 12:39:25 +10:00
parent 52b800df5c
commit 300d5664cb
7 changed files with 291 additions and 2 deletions

View File

@@ -46,9 +46,25 @@ function createPathCircle() {
}
return data
}
function createPathSpiral() {
const svg = d3.select("svg")
const width = svg.attr("width")
const height = svg.attr("height")
let data = [];
// используем параметрическую форму описания круга
// центр расположен в центре svg-элемента, а радиус равен трети высоты/ширины
for (let t = 0 ; t <= Math.PI * 6; t += 0.1) {
data.push(
{x: width / 2 + width / 3*(1-(t/Math.PI * 6)) * Math.sin(t),
y: height / 2 + height / 3*(1-(t/Math.PI * 6)) * Math.cos(t)}
);
}
return data
}
const drawPath =(typePath) => {
// создаем массив точек
const dataPoints = (typePath == 0)? createPathG() : createPathCircle();
const dataPoints = [createPathG,createPathCircle,createPathSpiral][Number(typePath)]()
const line = d3.line()
.x((d) => d.x)