#renderSurface() { const styles: Record<string, string> = {}; if (this.surface?.styles) { for (const [key, value] of Object.entries(this.surface.styles)) { switch (key) { // Here we generate a palette from the singular primary color received // from the surface data. We will want the values to range from // 0 <= x <= 100, where 0 = back, 100 = white, and 50 = the primary // color itself. As such we use a color-mix to create the intermediate // values. // // Note: since we use half the range for black to the primary color, // and half the range for primary color to white the mixed values have // to go up double the amount, i.e., a range from black to primary // color needs to fit in 0 -> 50 rather than 0 -> 100. case"primaryColor": {
styles["--p-100"] = "#ffffff";
styles["--p-99"] = `color-mix(in srgb, ${value} 2%, white 98%)`;
styles["--p-98"] = `color-mix(in srgb, ${value} 4%, white 96%)`;
styles["--p-95"] = `color-mix(in srgb, ${value} 10%, white 90%)`;
styles["--p-90"] = `color-mix(in srgb, ${value} 20%, white 80%)`;
styles["--p-80"] = `color-mix(in srgb, ${value} 40%, white 60%)`;
styles["--p-70"] = `color-mix(in srgb, ${value} 60%, white 40%)`;
styles["--p-60"] = `color-mix(in srgb, ${value} 80%, white 20%)`;
styles["--p-50"] = value;
styles["--p-40"] = `color-mix(in srgb, ${value} 80%, black 20%)`;
styles["--p-35"] = `color-mix(in srgb, ${value} 70%, black 30%)`;
styles["--p-30"] = `color-mix(in srgb, ${value} 60%, black 40%)`;
styles["--p-25"] = `color-mix(in srgb, ${value} 50%, black 50%)`;
styles["--p-20"] = `color-mix(in srgb, ${value} 40%, black 60%)`;
styles["--p-15"] = `color-mix(in srgb, ${value} 30%, black 70%)`;
styles["--p-10"] = `color-mix(in srgb, ${value} 20%, black 80%)`;
styles["--p-5"] = `color-mix(in srgb, ${value} 10%, black 90%)`;
styles["--0"] = "#00000"; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.