gpt4 book ai didi

javascript - 用SVG画圆

转载 作者:行者123 更新时间:2023-11-28 03:51:44 25 4
gpt4 key购买 nike

我想使用 SVG 画一个圆。圆的中心在阵列中。arr[i][0].x 是 x 中心,arr[i][0].y 是 y 中心,arr[i][0].r 是半径。

我尝试过这样的

svg.appendChild(circle);
circle.cx.appendItem(arr[i][0].x);
circle.cy.appendItem(arr[i][0].y);
circle.r.appendItem(arr[i][0].r);

但它不起作用。我该如何修复它?

最佳答案

使用setAttribute设置圆值。

 var circle = document.getElementById("circle")
circle.setAttribute("cx", 60);
circle.setAttribute("cy", 70);
circle.setAttribute("r", 5);
var svg = document.getElementById("svg1")
svg.appendChild(circle);

关于javascript - 用SVG画圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47940077/

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