mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-27 21:01:02 +00:00
Feat: Custom Games
This commit is contained in:
@@ -64,6 +64,54 @@ app.whenReady().then(async () => {
|
||||
return net.fetch(url.pathToFileURL(decodeURI(filePath)).toString());
|
||||
});
|
||||
|
||||
protocol.handle("gradient", (request) => {
|
||||
const gradientCss = decodeURIComponent(request.url.slice("gradient:".length));
|
||||
|
||||
const match = gradientCss.match(/linear-gradient\(([^,]+),\s*([^,]+),\s*([^)]+)\)/);
|
||||
|
||||
let direction = "45deg";
|
||||
let color1 = '#4a90e2';
|
||||
let color2 = '#7b68ee';
|
||||
|
||||
if (match) {
|
||||
direction = match[1].trim();
|
||||
color1 = match[2].trim();
|
||||
color2 = match[3].trim();
|
||||
}
|
||||
|
||||
let x1 = "0%", y1 = "0%", x2 = "100%", y2 = "100%";
|
||||
|
||||
if (direction === "to right") {
|
||||
x1 = "0%"; y1 = "0%"; x2 = "100%"; y2 = "0%";
|
||||
} else if (direction === "to bottom") {
|
||||
x1 = "0%"; y1 = "0%"; x2 = "0%"; y2 = "100%";
|
||||
} else if (direction === "45deg") {
|
||||
x1 = "0%"; y1 = "100%"; x2 = "100%"; y2 = "0%";
|
||||
} else if (direction === "135deg") {
|
||||
x1 = "0%"; y1 = "0%"; x2 = "100%"; y2 = "100%";
|
||||
} else if (direction === "225deg") {
|
||||
x1 = "100%"; y1 = "0%"; x2 = "0%"; y2 = "100%";
|
||||
} else if (direction === "315deg") {
|
||||
x1 = "100%"; y1 = "100%"; x2 = "0%"; y2 = "0%";
|
||||
}
|
||||
|
||||
const svgContent = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="300" viewBox="0 0 400 300">
|
||||
<defs>
|
||||
<linearGradient id="grad" x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}">
|
||||
<stop offset="0%" style="stop-color:${color1};stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:${color2};stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#grad)" />
|
||||
</svg>
|
||||
`;
|
||||
|
||||
return new Response(svgContent, {
|
||||
headers: { 'Content-Type': 'image/svg+xml' }
|
||||
});
|
||||
});
|
||||
|
||||
await loadState();
|
||||
|
||||
const language = await db
|
||||
|
||||
Reference in New Issue
Block a user