MCPcopy Create free account
hub / github.com/TheOrcDev/github-creature / hexToVec4

Function hexToVec4

components/balatro.tsx:23–40  ·  view source on GitHub ↗
(hex: string)

Source from the content-addressed store, hash-verified

21}
22
23function hexToVec4(hex: string): [number, number, number, number] {
24 const hexStr = hex.replace("#", "");
25 let r = 0,
26 g = 0,
27 b = 0,
28 a = 1;
29 if (hexStr.length === 6) {
30 r = parseInt(hexStr.slice(0, 2), 16) / 255;
31 g = parseInt(hexStr.slice(2, 4), 16) / 255;
32 b = parseInt(hexStr.slice(4, 6), 16) / 255;
33 } else if (hexStr.length === 8) {
34 r = parseInt(hexStr.slice(0, 2), 16) / 255;
35 g = parseInt(hexStr.slice(2, 4), 16) / 255;
36 b = parseInt(hexStr.slice(4, 6), 16) / 255;
37 a = parseInt(hexStr.slice(6, 8), 16) / 255;
38 }
39 return [r, g, b, a];
40}
41
42const vertexShader = `
43attribute vec2 uv;

Callers 1

BalatroFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected