color: 'rgb(' +
Math.round(Math.random() * 255) +
', ' +
Math.round(Math.random() * 255) +
', ' +
Math.round(Math.random() * 255) +
')',
这样生成的是随机颜色。但是生成的颜色中某些颜色不好看。我怎么才能生成一些漂亮的随机颜色。比如说,更改一下255,只生成部分好看的颜色。
你定义一段json 存储好看的颜色 然后随机 key 取value
第四个参数加上透明度把,透明度写死0.5,只要颜色不是太深,0.5差不多都挺好看的。
color: 'rgb(' +
Math.round(Math.random() * 255) +
', ' +
Math.round(Math.random() * 255) +
', ' +
Math.round(Math.random() * 255) +
', ' + ‘0.5’
')',