spiral path added
This commit is contained in:
@@ -22,9 +22,9 @@ html(lang="ru")
|
|||||||
input#cx_finish.anim-related(type="number", value="300", max="600", min="0")
|
input#cx_finish.anim-related(type="number", value="300", max="600", min="0")
|
||||||
br
|
br
|
||||||
label(for="cy") y:
|
label(for="cy") y:
|
||||||
input#cy.anim-related(type="number", value="300", max="600", min="0")
|
input#cy(type="number", value="300", max="600", min="0")
|
||||||
label.anim-related(for="cy_finish") до:
|
label.anim-related(for="cy_finish") до:
|
||||||
input#cy_finish(type="number", value="300", max="600", min="0")
|
input.anim-related#cy_finish(type="number", value="300", max="600", min="0")
|
||||||
|
|
||||||
p.path-anim-related
|
p.path-anim-related
|
||||||
| Пути перемещения
|
| Пути перемещения
|
||||||
|
|||||||
@@ -46,9 +46,24 @@ function createPathCircle() {
|
|||||||
}
|
}
|
||||||
return data
|
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 drawPath =(typePath) => {
|
||||||
// создаем массив точек
|
// создаем массив точек
|
||||||
const dataPoints = (typePath == 0)? createPathG() : createPathCircle();
|
const dataPoints = [ createPathG, createPathCircle,createPathSpiral][Number(typePath)]()
|
||||||
|
|
||||||
const line = d3.line()
|
const line = d3.line()
|
||||||
.x((d) => d.x)
|
.x((d) => d.x)
|
||||||
|
|||||||
Reference in New Issue
Block a user