| 1979 | } |
| 1980 | |
| 1981 | function hexToRgb565(hex) { |
| 1982 | hex = hex.replace("#", ""); |
| 1983 | if (hex.length === 3) { |
| 1984 | hex = hex |
| 1985 | .split("") |
| 1986 | .map((c) => c + c) |
| 1987 | .join(""); |
| 1988 | } |
| 1989 | const r = parseInt(hex.substr(0, 2), 16); |
| 1990 | const g = parseInt(hex.substr(2, 2), 16); |
| 1991 | const b = parseInt(hex.substr(4, 2), 16); |
| 1992 | |
| 1993 | const r5 = (r >> 3) & 0x1f; |
| 1994 | const g6 = (g >> 2) & 0x3f; |
| 1995 | const b5 = (b >> 3) & 0x1f; |
| 1996 | |
| 1997 | const rgb565 = (r5 << 11) | (g6 << 5) | b5; |
| 1998 | return "0x" + rgb565.toString(16).padStart(4, "0").toUpperCase(); |
| 1999 | } |
| 2000 | |
| 2001 | function elementHasText(type) { |
| 2002 | return ["text", "label", "button", "header", "card"].includes(type); |