html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RGB to Hex Background Color</title>
<script src="https://cdn.jsdelivr.net/npm/fengari-web@0.1.4/dist/fengari-web.js"></script>
</head>
<body>
<h1 align="center">Hex color generator</h1>
<strong>Explanation</strong>:
<p>Hex color codes work within 15 characters, 0-9 and a-f. RGB goes into hex color codes as such # (red) 00 (green) 00 (blue) 00. Hex color codes work by rolling over the value of 09 to 0a. Once 0f is hit (15) the following value (16) would be represented as 10 instead of (16). This means the RGB values (16, 32, 161) would evaluate to #1020a1 (10, 20, a1).</p>
<pre>
</pre>
<label for="r">R: <input type="number" id="r" min="0" max="255" value="255"></label>
<label for="g">G: <input type="number" id="g" min="0" max="255" value="255"></label>
<label for="b">B: <input type="number" id="b" min="0" max="255" value="255"></label>
<button onclick="changeColor()">Change Background</button>
<script type="text/lua" id="lua_code">
function rgb_to_hex(r, g, b)
local hex_chars = "0123456789abcdef"
local function to_hex(value)
return hex_chars:sub(math.floor(value / 16) + 1, math.floor(value / 16) + 1) ..
hex_chars:sub((value % 16) + 1, (value % 16) + 1)
end
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Ejecutar