1
想知道是否有人對DevTools中第三方徽章的重要性有所瞭解,並且特別是其顏色?他們各有不同,並且很好奇這是如何決定的以及爲什麼。Chrome DevTools中的第三方徽章:顏色
想知道是否有人對DevTools中第三方徽章的重要性有所瞭解,並且特別是其顏色?他們各有不同,並且很好奇這是如何決定的以及爲什麼。Chrome DevTools中的第三方徽章:顏色
顏色是根據產品名稱生成的(所以它們在重新加載之間是一致的)。他們沒有任何特殊的含義。
從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})`;
}
明白了。希望確保沒有任何意義。謝謝! –