I'm using svg to draw a circle and I would like to make the stroke color and fill color the same, but still random. Is there some way to randomize the color?
问问题
872 次
2 回答
1
Paul Irish有一篇关于这个问题的文章。
'#' + Math.floor(Math.random() * 16777215).toString(16);
于 2012-12-03T20:31:13.353 回答
0
function getColor(){
return '#'+Math.floor(Math.random() * 16777215).toString(16);
}
var myColor = getColor();
然后只是myColor
用来设置你的笔触和填充。
这将产生柔和的颜色。
示例:http: //jsfiddle.net/29rkd/
于 2012-12-03T20:33:00.933 回答