首页 > 解决方案 > 如何将笔画属性添加到绘制的元素?

问题描述

我有一个在我的 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 库)

标签: javascriptsvgsvg.js

解决方案


API 文档总共提到了五种可能性:

.stroke('#000') // seems hex notation is expected
.attr('stroke', 'black')
.attr({stroke: 'black'})
.style('stroke', 'black')
.style({stroke: 'black'})

推荐阅读