美文网首页
随机颜色

随机颜色

作者: 中建云筑股份有限公司 | 来源:发表于2018-04-09 09:09 被阅读0次

调用函数即可 会返回一个随机的rgb

function getRandomColor() {
  let rgb = []
  for (let i = 0; i < 3; ++i) {
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
  }
  return '#' + rgb.join('')
}

相关文章

  • 随机颜色

    调用函数即可 会返回一个随机的rgb

  • 随机颜色

    // UIColor+Hex.m创建继承于UIColor的类别 随机颜色 UIColor+Hex.h + (UIC...

  • 随机颜色

    - (UIColor*)randomColor {CGFloat red =arc4 random()%255/2...

  • 随机颜色

    flutter 产生随机颜色 相关代码如下: 需要导入以下两个 有了随机颜色妈妈再也不用但心选择颜色了~ 哈哈哈哈...

  • 随机颜色

    //随机颜色 intR = (arc4random() % 256) ; intG = (arc4rand...

  • 随机颜色

  • 随机颜色

  • 随机颜色

  • PHP实现验证码效果

    创建画布,创建随机颜色 在画布中写入验证码 在画布中写入随机颜色、随机位置、随机数量的点 在画布中写入随机颜色、随...

  • 字体随机,颜色随机

    字体颜色—随机 其中的字体家族名和字体名可以通过以下方法获取: NSLog(@"familyNames:%@",[...

网友评论

      本文标题:随机颜色

      本文链接:https://www.haomeiwen.com/subject/gfcezxtx.html