Ok.
I'm working with the FW1FontWrapper code for use with DirectX
:
https://archive.codeplex.com/?p=fw1
This has removed my need to use an outdated and useless font engine powered by textures.
However, the DrawString function within this Wrapper has a peculiar requirement for a Colour representation.
UINT32 Color : In the format 0xAaBbGgRr
The data I am given for this task is a constant Alpha value: 1.0f.
And 3 variable float values for R, G and B ranging from 0.0f to 1.0f.
Given the peculiar arrangement of colours within the UNIT32, I'm attempting to write a function that will create this UNIT32 using the 3 float values I am given.
My Attempt
UINT32 TextClassA::getColour(SentenceType* sentence)
{
//Convert each float value to its percentage of 255
int colorb = 255 * sentence->blue;
int colorg = 255 * sentence->green;
int colorr = 255 * sentence->red;
//convert each int to 8 bit Hex
UINT8 ucolorb = colorb;
UINT8 ucolorg = colorg;
UINT8 ucolorr = colorr;
//Push each hex back onto a UNIT32
UINT32 color = 0xFF + (ucolorb << 6) + (ucolorg << 4) + (ucolorr << 2);
return color;
}
SentenceType
red, green and blue are simply floats for each value of RGB from 0.0-1.0f
My Idea.
Was roughly that I could:
convert each float value to its percentage of 255 (not too worried about perfect accuracy.
Convert those integer values to UINT8s
Then push those back onto a UINT32
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)