目录
当前位置: 首页 > 文档资料 > Snap.svg 英文文档 >

Snap.getRGB(color)

优质
小牛编辑
127浏览
2023-12-01

Parses color string as RGB object

Parameters

  1. colorstringcolor string in one of the followingformats:
  • Color name (red, green,cornflowerblue, etc)
  • #••• — shortened HTML color: (#000,#fc0, etc.)
  • #•••••• — full length HTML color: (#000000,#bd2300)
  • rgb(•••, •••, •••) — red, green and blue channelsvalues: (rgb(200, 100, 0))
  • rgba(•••, •••, •••, •••) — also with opacity
  • rgb(•••%, •••%, •••%) — same as above, but in%: (rgb(100%, 175%, 0%))
  • rgba(•••%, •••%, •••%, •••%) — also with opacity
  • hsb(•••, •••, •••) — hue, saturation and brightnessvalues: (hsb(0.5, 0.25, 1))
  • hsba(•••, •••, •••, •••) — also with opacity
  • hsb(•••%, •••%, •••%) — same as above, but in%
  • hsba(•••%, •••%, •••%, •••%) — also with opacity
  • hsl(•••, •••, •••) — hue, saturation and luminosityvalues: (hsb(0.5, 0.25, 0.5))
  • hsla(•••, •••, •••, •••) — also with opacity
  • hsl(•••%, •••%, •••%) — same as above, but in%
  • hsla(•••%, •••%, •••%, •••%) — also with opacity

Note that % can be used any time: rgb(20%, 255, 50%).

Returns: object RGB object in the following format:

  1. {
    1. r numberred,
    2. g numbergreen,
    3. b numberblue,
    4. hex stringcolor in HTML/CSS format: #••••••,
    5. error booleantrue if string can't be parsed
  2. }