Try It: RGB Color Mixer
Try Start with Red (0-255) at 128, Green (0-255) at 64 and Blue (0-255) at 200, then move the green slider.
Observe The initial swatch is #8040C8, with Perceived Brightness 99 / 255 and estimated combined current 30.7 mA.
Explain Green (0-255) has the largest brightness weight; the tool adds weighted red, green and blue values and rounds the result.
Calculate RGB mix
Reset
Technical boundaries. The current estimate assumes each channel draws 20 mA at its maximum value and scales linearly below it. Brightness uses fixed weights of 0.299, 0.587 and 0.114 without an LED or display calibration model.
viewof red_val = Inputs. range ([0 , 255 ], {value : 128 , step : 1 , label : "Red (0-255)" })
viewof green_val = Inputs. range ([0 , 255 ], {value : 64 , step : 1 , label : "Green (0-255)" })
viewof blue_val = Inputs. range ([0 , 255 ], {value : 200 , step : 1 , label : "Blue (0-255)" })
rgb_hex = "#" + red_val. toString (16 ). padStart (2 , "0" ) + green_val. toString (16 ). padStart (2 , "0" ) + blue_val. toString (16 ). padStart (2 , "0" )
rgb_brightness = Math . round ((red_val * 0.299 + green_val * 0.587 + blue_val * 0.114 ))
rgb_total_current = (red_val / 255 * 20 ) + (green_val / 255 * 20 ) + (blue_val / 255 * 20 )
html `<div style="background: var(--bs-light, #f8f9fa); padding: 1rem; border-radius: 8px; border-left: 4px solid #9B59B6; margin-top: 0.5rem;">
<div style="display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;">
<div style="width: 100px; height: 100px; border-radius: 50%; background: ${ rgb_hex} ; border: 2px solid #2C3E50; box-shadow: 0 0 ${ rgb_brightness / 5 } px ${ rgb_hex} ;"></div>
<div>
<p style="margin: 0.25rem 0;"><strong>HEX:</strong> <code> ${ rgb_hex. toUpperCase ()} </code></p>
<p style="margin: 0.25rem 0;"><strong>RGB:</strong> <code>setColor( ${ red_val} , ${ green_val} , ${ blue_val} )</code></p>
<p style="margin: 0.25rem 0;"><strong>Perceived Brightness:</strong> ${ rgb_brightness} / 255 ( ${ Math . round (rgb_brightness / 255 * 100 )} %)</p>
<p style="margin: 0.25rem 0;"><strong>Est. Total Current:</strong> ${ rgb_total_current. toFixed (1 )} mA (3 channels combined)</p>
</div>
</div>
<div style="display: flex; gap: 0.5rem; margin-top: 0.75rem;">
<div style="flex: 1; height: 20px; border-radius: 4px; background: linear-gradient(to right, #000, rgb(255,0,0)); opacity: ${ red_val / 255 } ;"></div>
<div style="flex: 1; height: 20px; border-radius: 4px; background: linear-gradient(to right, #000, rgb(0,255,0)); opacity: ${ green_val / 255 } ;"></div>
<div style="flex: 1; height: 20px; border-radius: 4px; background: linear-gradient(to right, #000, rgb(0,0,255)); opacity: ${ blue_val / 255 } ;"></div>
</div>
<p style="font-size: 0.85em; color: #7F8C8D; margin-top: 0.5rem;"><em>Perceived brightness uses the ITU-R BT.601 luminance formula: 0.299R + 0.587G + 0.114B. Green contributes most to perceived brightness because human eyes are most sensitive to green light.</em></p>
</div>`
Back to the chapter