User:An Orbit/Loona member box code: Difference between revisions

From R74n Wikibase
Jump to navigation Jump to search
(heck)
(No difference)

Revision as of 14:46, 6 June 2023

The following JS code uses functions from Sandboxels's code_library.js mod. It can be used by running the code in a browser JavaScript console while in a Sandboxels tab that has the mod enabled and loaded.

loona = [
	{name: "HeeJin", color: "#FF007F", emoji: "🐰"},
	{name: "HyunJin", color: "#fffb00", emoji: "ðŸą"},
	{name: "HaSeul", color: "#00cc00", emoji: "🕊"},
	{name: "YeoJin", color: "#ff7f00", emoji: "ðŸļ"},
	{name: "ViVi", color: "#ffcfff", emoji: "ðŸĶŒ"},
	{name: "Kim Lip", color: "#fc1e1e", emoji: "ðŸĶ‰"},
	{name: "JinSoul", color: "#0f87ff", emoji: "ðŸŊ"}, //officially 🐟
	{name: "Choerry", color: "#8f00bf", emoji: "ðŸŋ"}, //officially ðŸĶ‡
	{name: "Yves", color: "#7f005f", emoji: "ðŸĶĒ"},
	{name: "Chuu", color: "#ffb980", emoji: "🐧"},
	{name: "Go Won", color: "#97efaf", emoji: "ðŸĶ‹"},
	{name: "Hyeju", color: "#afafaf", emoji: "🐚"} //Olivia Hye
];

function getY(color) {
	var color = convertHslObjects(normalizeColorToHslObject(color),"rgbjson");
	return (0.2126 * color.r) + (0.7152 * color.g) + (0.0722 * color.b)
};

var userboxesOut = "";

for(var i in loona) {
	var border = changeLuminance(data.color,6.5,"set","hex");

	var data = loona[i];
	var leftBack = changeLuminance(changeSaturation(data.color,0.99,"multiply","hsljson"),1.06,"multiply","hex");
	var rightBack = data.color;
	
	var backgroundBrightness = getY(data.color);
	var textColorToUse = backgroundBrightness > 175 ? "black" : "white"
	var leftFront = textColorToUse;
	var rightFront = textColorToUse;

	var leftText = data.emoji + "ïļ"; // U+FE0F emoji variation selector
	var rightText = `This user loves ${data.name}`;

	userboxesOut += `{{User:An Orbit/2 text userbox
|border-color = ${border}
|left-background-color = ${leftBack}
|left-text-color = ${leftFront}
|left-text = ${leftText}
|right-background-color = ${rightBack}
|right-text-color = ${rightFront}
|right-text = ${rightText}
}}`
};

copy(userboxesOut)