2017-10-16 74 views

回答

0

顏色是根據產品名稱生成的(所以它們在重新加載之間是一致的)。他們沒有任何特殊的含義。

BadgePool.js(其中entryName可能是類似 「谷歌分析」):

static colorForEntryName(entryName) { 
    if (!ProductRegistry.BadgePool._colorGenerator) { 
     ProductRegistry.BadgePool._colorGenerator = 
      new Common.Color.Generator({min: 30, max: 330}, {min: 50, max: 80, count: 3}, 80); 
    } 
    return ProductRegistry.BadgePool._colorGenerator.colorForID(entryName); 
    } 

而且從Common.Color.Generator:

/** 
    * @param {string} id 
    * @return {string} 
    */ 
    colorForID(id) { 
    var color = this._colors.get(id); 
    if (!color) { 
     color = this._generateColorForID(id); 
     this._colors.set(id, color); 
    } 
    return color; 
    } 

    /** 
    * @param {string} id 
    * @return {string} 
    */ 
    _generateColorForID(id) { 
    var hash = String.hashCode(id); 
    var h = this._indexToValueInSpace(hash, this._hueSpace); 
    var s = this._indexToValueInSpace(hash >> 8, this._satSpace); 
    var l = this._indexToValueInSpace(hash >> 16, this._lightnessSpace); 
    var a = this._indexToValueInSpace(hash >> 24, this._alphaSpace); 
    return `hsla(${h}, ${s}%, ${l}%, ${a})`; 
    } 
+1

明白了。希望確保沒有任何意義。謝謝! –