javascript 拉斐尔:设置线条颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6265874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:05:17  来源:igfitidea点击:

Raphael: Set Line Color

javascriptraphael

提问by Nik

I am using the Raphael JS vector library and I cannot get a line (path) that I am drawing to change colors. Hopefully it's just something stupid I did.

我正在使用 Raphael JS 矢量库,但无法获得正在绘制以更改颜色的线(路径)。希望这只是我做的一些愚蠢的事情。

var blue_one = paper.path ("M205 205L300 300");
blue_one.attr ("stroke-width", "3");
blue_one.attr ("fill", "#0000FF");

I have also tried fill values of "#00F", "blue", "0000FF", and "00F".

我还尝试了“#00F”、“蓝色”、“0000FF”和“00F”的填充值。

回答by Andrew

This is what you want to set.

这就是您要设置的内容。

blue_one.attr ("stroke", "#0000FF");

For a full listing of the properties, see the Specificationor the Raphael Documentation

有关属性的完整列表,请参阅规范Raphael 文档

回答by rohan_vg

Can be written simply in one line like this.

可以像这样简单地写在一行中。

var blue_one = paper.path ("M205 205L300 300").attr({stroke:'#0000FF'});