Codex changes
This commit is contained in:
parent
0bae902e08
commit
d4dde21ad2
46 changed files with 4953 additions and 966 deletions
|
|
@ -44,6 +44,46 @@ export const FEATURE_GRADIENT: { t: number; color: [number, number, number] }[]
|
|||
{ t: 1, color: [142, 68, 173] },
|
||||
];
|
||||
|
||||
export type GradientStop = { t: number; color: [number, number, number] };
|
||||
|
||||
function partyGradient(color: [number, number, number]): GradientStop[] {
|
||||
return [
|
||||
{ t: 0, color: [255, 255, 255] },
|
||||
{
|
||||
t: 0.5,
|
||||
color: [
|
||||
Math.round(255 + (color[0] - 255) * 0.45),
|
||||
Math.round(255 + (color[1] - 255) * 0.45),
|
||||
Math.round(255 + (color[2] - 255) * 0.45),
|
||||
],
|
||||
},
|
||||
{ t: 1, color },
|
||||
];
|
||||
}
|
||||
|
||||
/** UK party colours for the 2024 General Election vote-share map layers. */
|
||||
export const PARTY_FEATURE_GRADIENTS: Record<string, GradientStop[]> = {
|
||||
'% Labour': partyGradient([228, 0, 59]), // Labour red
|
||||
'% Conservative': partyGradient([0, 135, 220]), // Conservative blue
|
||||
'% Liberal Democrat': partyGradient([255, 100, 0]), // Liberal Democrat orange
|
||||
'% Reform UK': partyGradient([18, 182, 207]), // Reform UK cyan
|
||||
'% Green': partyGradient([106, 176, 35]), // Green Party green
|
||||
'% Other parties': partyGradient([107, 114, 128]), // neutral fallback for grouped parties
|
||||
};
|
||||
|
||||
export const PARTY_FEATURE_COLORS: Record<string, string> = Object.fromEntries(
|
||||
Object.entries(PARTY_FEATURE_GRADIENTS).map(([featureName, gradient]) => {
|
||||
const color = gradient[gradient.length - 1].color;
|
||||
return [featureName, `rgb(${color[0]}, ${color[1]}, ${color[2]})`];
|
||||
})
|
||||
);
|
||||
|
||||
export function getFeatureGradient(featureName: string | null | undefined): GradientStop[] {
|
||||
return featureName
|
||||
? (PARTY_FEATURE_GRADIENTS[featureName] ?? FEATURE_GRADIENT)
|
||||
: FEATURE_GRADIENT;
|
||||
}
|
||||
|
||||
/** Number of properties gradient — light mode (cream → orange) */
|
||||
export const DENSITY_GRADIENT: { t: number; color: [number, number, number] }[] = [
|
||||
{ t: 0, color: [255, 255, 255] },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue