r/FastLED • u/Burning_Wreck • Dec 06 '23
Code_samples Code format question
In this example: https://github.com/marmilicious/FastLED_examples/blob/master/blend_to_target_color.ino
Line 43 reads:if ( colorCurrent.h == colorTarget.h ) { // Check if target has been reached
I'm not familiar with the use of .h as part of a variable. If I delete both ".h" then the code works fine.
And I can't figure out how to Google this one. Any hints here?
2
Upvotes
•
u/Marmilicious [Marc Miller] Dec 06 '23
Example linked by OP has been updated for better clarity and info about using HSV.
In the previously linked version comparing
colorCurrent.h == colorTarget.horcolorCurrent == colorTargetwithout the .h worked the same since the colors were fully saturated and at full brightness. ComparingcolorCurrent == colorTargetcompares the H,S, and V numbers all at the same time.4
u/ShreddinPB Dec 06 '23
I think what might be confusing you is the use of .h
Those are not header files. The variable type is a "CHSV" which is really a struct of 3 variables.
So colorCurrent.h get the Hue, colorCurrent.s gets the saturation, and colorCurrent.v gets the value.
2
u/macegr Dec 06 '23
It’s blending between full brightness and full saturated colors and only cares about checking whether hue matches.