mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-14 23:34:01 -04:00
them towards theme controlCenter: make a real grid, add numerous more tile varieties, add icon size option surfaces: fix elevation levels in general, and shift them down settings: restyles and re-org sliders: scale down universally
27 lines
836 B
JavaScript
27 lines
836 B
JavaScript
.pragma library
|
|
|
|
var MIN_CHANNEL_DELTA = 0.1;
|
|
|
|
function distinct(a, b) {
|
|
const ca = Qt.color(a);
|
|
const cb = Qt.color(b);
|
|
return Math.max(Math.abs(ca.r - cb.r), Math.abs(ca.g - cb.g), Math.abs(ca.b - cb.b)) >= MIN_CHANNEL_DELTA;
|
|
}
|
|
|
|
function firstDistinct(candidates, taken) {
|
|
return candidates.find(c => c && taken.every(t => distinct(c, t)));
|
|
}
|
|
|
|
function pick(scheme) {
|
|
if (!scheme?.primary)
|
|
return null;
|
|
const primary = scheme.primary;
|
|
const secondary = firstDistinct([scheme.secondary, scheme.tertiary, scheme.primaryContainer, scheme.info], [primary]) ?? primary;
|
|
const tertiary = firstDistinct([scheme.tertiary, scheme.info, scheme.error, scheme.warning, scheme.primaryContainer], [primary, secondary]) ?? secondary;
|
|
return {
|
|
primary,
|
|
secondary,
|
|
tertiary
|
|
};
|
|
}
|