gpt4 book ai didi

javascript - d3 转换不遵循路径

转载 作者:行者123 更新时间:2023-12-01 03:00:36 25 4
gpt4 key购买 nike

我喜欢让飞机沿着路径行驶。但无论我尝试过什么,过渡路径和屏幕上实际绘制的路径之间都会发生变化。请查看jsfiddle

d3.selectAll('.aircraft').transition()
.duration(7500)
.attrTween('transform', translateAlong(d3.select('#samplePath').node()))

function translateAlong(path) {
let l = path.getTotalLength()
// debugger
return function (i) {
return function (t) {
let p = path.getPointAtLength(t * l)
console.log(p.x, p.y)
return 'matrix(-0.359863 -0.230143 0.230143 -0.359863' + p.x + ' ' + p.y + ')'
}
}
}

最佳答案

矩阵定义中第二个 -0.359863 后面缺少一个空格:

return 'matrix(-0.359863 -0.230143 0.230143 -0.359863 ' +  p.x + ' ' + p.y + ')'

关于javascript - d3 转换不遵循路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46445361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com