javascript - 如何将笔画属性添加到绘制的元素?
问题描述
我有一个在我的 svg 元素上绘制圆圈的函数:
function drawCircle( pElem, pX, pY)
{
pElem.circle( 7 ).fill( '#00FF00' ).move( pX, pY );
} //drawCircle
但我想像这样向绘制的元素添加黑色笔触:
function drawCircle( pElem, pX, pY)
{
pElem.circle( 7 ).fill( '#00FF00' ).move( pX, pY ).style.stroke = 'black'; //tried this but it didn't work
} //drawCircle
我怎样才能做到这一点?(注意:我使用的是 svg.js 库)
解决方案
API 文档总共提到了五种可能性:
.stroke('#000') // seems hex notation is expected
.attr('stroke', 'black')
.attr({stroke: 'black'})
.style('stroke', 'black')
.style({stroke: 'black'})
推荐阅读
- html - 如何通过自定义 CSS 更改阿拉伯语 RTL 下拉子菜单的方向?
- deployment - 管理代理产品上的就绪探测失败
- python - 如果我有中点、角度和长度,则获取一条线的端点
- mongodb - 猫鼬集成问题(又名 insertMany)
- swiftui - 似乎无法在 text() 和 textfield() 之间使用 Spacer()
- python - 如何不在“for循环”中打印重复字符?
- browser - PuppeteerSharp 向本地主机请求?
- reactjs - redux 减速器类型“从不”
- matlab - 在 MATLAB 中构建 3D 点阵图
- javascript - 传递给孩子的反应道具没有通过