summaryrefslogtreecommitdiff
path: root/libs/rs/rsScriptC_Lib.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-07-31 15:33:59 -0700
committerRomain Guy <romainguy@android.com>2009-07-31 21:36:18 -0700
commita32d100b34d048cf0c765d8f31d87b81ab88d1eb (patch)
treed0393450dfb3abcbe2aa44aca5b3e289360b19b2 /libs/rs/rsScriptC_Lib.cpp
parent4aa38681c6daa932fc1642dbf27dc2f938771147 (diff)
Add new utility methods to rsScriptC_Lib, android.util.MathUtil and android.graphics.Color.
Fixes RS compilation.
Diffstat (limited to 'libs/rs/rsScriptC_Lib.cpp')
-rw-r--r--libs/rs/rsScriptC_Lib.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 21c975383c7c..e4979ea3b2d0 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -566,6 +566,59 @@ static void SC_color(float r, float g, float b, float a)
glColor4f(r, g, b, a);
}
+static void SC_hsb(float h, float s, float b, float a)
+{
+ float red = 0.0f;
+ float green = 0.0f;
+ float blue = 0.0f;
+
+ float x = h;
+ float y = s;
+ float z = b;
+
+ float hf = (x - (int) x) * 6.0f;
+ int ihf = (int) hf;
+ float f = hf - ihf;
+ float pv = z * (1.0f - y);
+ float qv = z * (1.0f - y * f);
+ float tv = z * (1.0f - y * (1.0f - f));
+
+ switch (ihf) {
+ case 0: // Red is the dominant color
+ red = z;
+ green = tv;
+ blue = pv;
+ break;
+ case 1: // Green is the dominant color
+ red = qv;
+ green = z;
+ blue = pv;
+ break;
+ case 2:
+ red = pv;
+ green = z;
+ blue = tv;
+ break;
+ case 3: // Blue is the dominant color
+ red = pv;
+ green = qv;
+ blue = z;
+ break;
+ case 4:
+ red = tv;
+ green = pv;
+ blue = z;
+ break;
+ case 5: // Red is the dominant color
+ red = z;
+ green = pv;
+ blue = qv;
+ break;
+ }
+
+ glColor4f(red, green, blue, a);
+}
+
/*
extern "C" void materialDiffuse(float r, float g, float b, float a)
{
@@ -650,7 +703,7 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = {
{ "atanf", (void *)&atanf,
"float", "(float)" },
{ "atan2f", (void *)&atan2f,
- "float", "(floatm float)" },
+ "float", "(float, float)" },
{ "fabsf", (void *)&fabsf,
"float", "(float)" },
{ "randf", (void *)&SC_randf,
@@ -772,6 +825,8 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = {
"void", "(float, float, float, float)" },
{ "color", (void *)&SC_color,
"void", "(float, float, float, float)" },
+ { "hsb", (void *)&SC_hsb,
+ "void", "(float, float, float, float)" },
{ "uploadToTexture", (void *)&SC_uploadToTexture,
"void", "(int, int)" },