change hsb to doubles internally

This commit is contained in:
marauder2k7 2025-01-22 20:12:49 +00:00
parent 5ca1c37fe9
commit 029a495de1
6 changed files with 73 additions and 51 deletions

View file

@ -1095,7 +1095,7 @@ DefineEngineFunction(ColorRGBToHEX, const char*, (ColorI color), ,
return Con::getReturnBuffer(color.getHex());
}
DefineEngineFunction(ColorRGBToHSB, Point3I, (ColorI color), ,
DefineEngineFunction(ColorRGBToHSB, const char*, (ColorI color), ,
"Convert from a integer RGB (red, green, blue) color to HSB (hue, saturation, brightness). HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n"
"@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n"
"@return HSB color value, alpha isn't handled/converted so it is only the RGB value\n\n"
@ -1104,9 +1104,9 @@ DefineEngineFunction(ColorRGBToHSB, Point3I, (ColorI color), ,
"@endtsexample\n"
"@ingroup Strings")
{
ColorI::Hsb hsb(color.getHSB());
Point3I hsbPoint(hsb.hue, hsb.sat, hsb.brightness);
return hsbPoint;
ColorI::Hsb hsb(color.getHSB());
String s(String::ToString(hsb.hue) + " " + String::ToString(hsb.sat) + " " + String::ToString(hsb.brightness));
return Con::getReturnBuffer(s);
}
DefineEngineFunction(ColorHEXToRGB, ColorI, (const char* hex), ,

View file

@ -409,6 +409,27 @@ ConsoleSetType( TypeS32Vector )
else
Con::printf("Vector<S32> must be set as { a, b, c, ... } or \"a b c ...\"");
}
//-----------------------------------------------------------------------------
// TypeF64
//-----------------------------------------------------------------------------
ConsoleType(double, TypeF64, F64, "")
ImplementConsoleTypeCasters(TypeF64, F64)
ConsoleGetType(TypeF64)
{
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%Lg", *((F64*)dptr));
return returnBuffer;
}
ConsoleSetType(TypeF64)
{
if (argc == 1)
*((F64*)dptr) = dAtod(argv[0]);
else
Con::printf("(TypeF64) Cannot set multiple args to a single F64.");
}
//-----------------------------------------------------------------------------
// TypeF32

View file

@ -66,6 +66,7 @@ DefineConsoleType( TypeBoolVector, Vector<bool>)
DefineConsoleType( TypeS8, S8 )
DefineConsoleType( TypeS32, S32 )
DefineConsoleType( TypeS32Vector, Vector<S32> )
DefineConsoleType( TypeF64, F64 )
DefineConsoleType( TypeF32, F32 )
DefineConsoleType( TypeF32Vector, Vector<F32> )
DefineUnmappedConsoleType( TypeString, const char * ) // plain UTF-8 strings are not supported in new interop