https://github.com/vendicated/pride
🏳️🌈 LGBT pride via github languages list 🏳️🌈
https://github.com/vendicated/pride
Last synced: about 1 year ago
JSON representation
🏳️🌈 LGBT pride via github languages list 🏳️🌈
- Host: GitHub
- URL: https://github.com/vendicated/pride
- Owner: Vendicated
- Created: 2023-11-19T17:00:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-19T17:17:02.000Z (over 2 years ago)
- Last Synced: 2025-02-09T16:38:12.196Z (over 1 year ago)
- Language: Promela
- Homepage:
- Size: 15.6 KB
- Stars: 63
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🏳️🌈 LGBT pride
LGBT pride via github languages list

Inspired by https://github.com/spacekookie/gay
Unfortunately, spacekookie's repo broke, because the OCaml language colour was changed.
Thus, i decided to make my own variant and make the colours as close to the original flag as possible.
To find the closest coloured languages, i wrote this incredibly shitty script
based on https://gist.github.com/Ademking/560d541e87043bfff0eb8470d3ef4894
```js
const linguistYaml = await fetch("https://raw.githubusercontent.com/github-linguist/linguist/master/lib/linguist/languages.yml").then(r => r.text());
const baseColors = Array.from(
linguistYaml.matchAll(/(^[^\n:]+):\n type: programming\n color: "(#\w{6})"/gm),
([, name, hex]) => ({ name, hex }));
function hexToRgb(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
// Distance between 2 colors (in RGB)
// https://stackoverflow.com/questions/23990802/find-nearest-color-from-a-colors-list
function distance(a, b) {
return Math.sqrt(Math.pow(a.r - b.r, 2) + Math.pow(a.g - b.g, 2) + Math.pow(a.b - b.b, 2));
}
// return nearest color from array
function nearestColor(colorHex) {
var lowest = Number.POSITIVE_INFINITY;
var tmp;
let index = 0;
baseColors.forEach((el, i) => {
tmp = distance(hexToRgb(colorHex), hexToRgb(el.hex));
if (tmp < lowest) {
lowest = tmp;
index = i;
};
});
return baseColors[index];
}
const LgbtColors = [
{
name: "Red",
hex: "#E40303",
},
{
name: "Orange",
hex: "#FF8C00"
},
{
name: "Yellow",
hex: "#FFED00"
},
{
name: "Green",
hex: "#008026"
},
{
name: "Blue",
hex: "#24408E",
},
{
name: "Purple",
hex: "#732982"
}
];
for (const { name, hex } of LgbtColors) {
console.log(`${name} -> ${nearestColor(hex).name}`);
}
```