Converting RGB value to Integer
See original GitHub issueThe Problem:
I would like to add a more following function in to the app:
-
Function for converting RGB value to integer. → Show live value on the interface (same like #HEX value) → Able to input the number, and change the color. → Able to pass the current value to another function in my app.
-
Ability to add a blank custom input field into the interfaces (with editable caption) → This doesn’t need to show any value, I’d like that use can able to type input by themselves.
The Solution:
Converting function is pretty simple as below, but I don’t know how to add it into the app…
// convert three r,g,b integers (each 0-255) to a single decimal integer (something between 0 and ~16m)
function colourToNumber(r, g, b) {
return (r << 16) + (g << 8) + (b);
}
// convert it back again (to a string)
function numberToColour(number) {
const r = (number & 0xff0000) >> 16;
const g = (number & 0x00ff00) >> 8;
const b = (number & 0x0000ff);
return [r, g, b];
// or eg. return `rgb(${r},${g},${b})`;
}
Could you help me please? contact: pc@passch.com
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Convert RGB values to Integer - java - Stack Overflow
// rgbs is an array of integers, every single integer represents the // RGB values combined in some way int r = (int)...
Read more >RGB Int Calculator - Shodor
This page will let you enter in RGB values, and by pressing evaluate, see the correspinding hexadecimal and integer representations of the color....
Read more >Convert RGB to Decimal - Color Conversions - CheckYourMath
Online calculator to convert RGB to Decimal color values. Our conversions provide a quick and easy way to convert between Color units.
Read more >Java Utililty Methods RGB Color Convert To - Java2s.com
Method ; int, RGBtoInt(int r, int g, int b) Converts RGB values to an RGB integer value. return (256 * 256 * r...
Read more >algorithm to convert integer to 3 variables (rgb)
I try to store integer (real numbers) values into pixel data. The only way my api can store pixel data are RGB Colors....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you @Wondermarin 😃
This is related with bug #25, which has already been fixed. The update will be released this week.