首页 > 解决方案 > 这些是什么类型的 Javascript 颜色代码?

问题描述

我遇到了这个 JS 代码我想知道什么样的颜色代码是示例:00190705 你们有谁知道它是什么以及如何生成其他代码?因为我需要添加其他人或修改现有的,我无法在网上的任何地方找到它们。

代码:

  "items" : [ {
    "guid" : "BCC-21188_20181108_DYE_01_01",
    "color_intensities" : "100",
    "color_number" : "BR-1",
    "colors" : {
      "color" : "0037211a"
    },
    "shine_intensities" : "50",
    "sku_guid" : "BCC-21188_20181108_DYE_01",
    "hair_dye_mode" : "salon",
    "itemLongName" : "Auburn brown"
  }, {
    "guid" : "BCC-21188_20181108_DYE_01_02",
    "color_intensities" : "100",
    "color_number" : "BR-2",
    "colors" : {
      "color" : "000b0604"
    },
    "shine_intensities" : "50",
    "sku_guid" : "BCC-21188_20181108_DYE_01",
    "hair_dye_mode" : "salon",
    "itemLongName" : "Chocolate brown"
  }, {
    "guid" : "BCC-21188_20181108_DYE_01_03",
    "color_intensities" : "100",
    "color_number" : "BR-3",
    "colors" : {
      "color" : "00030201"
    },
    "shine_intensities" : "50",
    "sku_guid" : "BCC-21188_20181108_DYE_01",
    "hair_dye_mode" : "salon",
    "itemLongName" : "Dark brown"
  }, {
    "guid" : "BCC-21188_20181108_DYE_01_04",
    "color_intensities" : "100",
    "color_number" : "BR-4",
    "colors" : {
      "color" : "005c4630"
    },
    "shine_intensities" : "50",
    "sku_guid" : "BCC-21188_20181108_DYE_01",
    "hair_dye_mode" : "salon",
    "itemLongName" : "Light brown"
  }, {
    "guid" : "BCC-21188_20181108_DYE_01_05",
    "color_intensities" : "100",
    "color_number" : "BR-5",
    "colors" : {
      "color" : "002c1d11"
    },
    "shine_intensities" : "50",
    "sku_guid" : "BCC-21188_20181108_DYE_01",
    "hair_dye_mode" : "salon",
    "itemLongName" : "Warm brown" ```

thank you

标签: javascript

解决方案


它们看起来像 32 位十六进制“XXRRGGBB”(X 表示未使用),其中最高字节为 00。

由于最高字节无关紧要,您只需将其替换为 a#即可获得常规的#RRGGBB 十六进制颜色,例如

"002c1d11".replace(/^00/, '#')

要得到

'#2c1d11'

这确实是一种非常深的棕色:

在此处输入图像描述


推荐阅读