LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate all colors from a start middle and end color

I searched and found a way to generate gradient colors with a start a middle and an end color and then generate the hex code of that color.

The thing is that I need to generate all colors that are close to the middle color, and that's why I used white as start color and black as finish color.

The thing is that to my surprise, I am not getting all the color values I need.

Can someone please help me generate all color value hex codes of the colors that are similar to the middle color value?

0 Kudos
Message 1 of 10
(5,091 Views)

You did not attach your sub vi.

 

Its easier to do if you think in HEX

Splt numbers is your friend here take a color box constant split it into 2 U16s  Split those into 4 U8s Ignore the highest (it is 0)

 

Pick one R, G, B to remain constant  Red is the second U8 Green the Third, Blue the least significant.

 

Run the other two though something like this

Capture Start.PNG

Then join the numbers again (00-R & G- B to u16) and (00R-GB to U32) Bobs your uncle

 

You can play with inconsistent treatment of the tow variable colors.  You might not like it but it might be psychedelic. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(5,071 Views)

I have taken a slightly different approach that what Jeff illustrated.

 

Yes start by splitting the colors into RGB values. Then create a ramp first between Red-Start and Red-Middle (do the same for the G and B) and then generate the ramp for Red-Middle to Red-End (same for the G and B).

 

Concantenate the R-ramps (same for G and B) then use the three resulting arrays in a For loop to "Join" the RGB back as colors.

 

No psychedelic effects and nice smooth color ramps.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 10
(5,047 Views)

This thread has a solution on this topic from Greg McKaskle himself.

 

Spoiler
From back in the days prior to LV 7 and the discussion forums did not support images let alone code sharing! Those were the days.

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 10
(5,040 Views)

Can you please help me, by attaching the vi?

I am a complete newbie when it comes to hexadecimal numbers.

Thanks.

0 Kudos
Message 5 of 10
(5,038 Views)

What I need is all the possible hex color values that are similar to a specific color.

0 Kudos
Message 6 of 10
(5,033 Views)

@Nando88 wrote:

Can you please help me, by attaching the vi?

I am a complete newbie when it comes to hexadecimal numbers.

Thanks.


Speaking only for myself... No.

 

1) I would be fired

2) I would screw up a perfectly wonderful and fun opportunity for you to learn about Hex.

 

Besides, it may not be exactly what you need. Code up what you can figure out, post when you get stuck and someone may be able to help you get over the rough spots.

 

And remember, Have Fun! After all you get a chance to code this up in LabVIEW.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 10
(5,026 Views)

Example_VI_BD.png

https://www.screencast.com/t/oejlq5fs

 

Unable to display content. Adobe Flash is required.

"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(5,022 Views)

Ben wrote:

Concantenate the R-ramps (same for G and B) then use the three resulting arrays in a For loop to "Join" the RGB back as colors.


No need for the FOR loop.  The Join Numbers will accept arrays.

 

Otherwise, my solution would be similar to what you already described.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(4,983 Views)

I've used this set of code for doing color gradients in the past.

 

https://forums.ni.com/t5/Example-Programs/Gradient-Color-Ramp-Scrolling/ta-p/3524938

 

I don't think it does exactly what you want but might be more flexible.

0 Kudos
Message 10 of 10
(4,969 Views)