diff options
Diffstat (limited to 'libs/rs')
| -rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain2.rs | 28 | ||||
| -rw-r--r-- | libs/rs/java/ImageProcessing/res/raw/threshold2.rs | 49 |
2 files changed, 63 insertions, 14 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain2.rs b/libs/rs/java/Fountain/res/raw/fountain2.rs index 3301140..5d36e35 100644 --- a/libs/rs/java/Fountain/res/raw/fountain2.rs +++ b/libs/rs/java/Fountain/res/raw/fountain2.rs @@ -1,9 +1,9 @@ // Fountain test script #pragma version(1) -#include "rs_types.rsh" -#include "rs_math.rsh" -#include "rs_graphics.rsh" +#include "../../../../scriptc/rs_types.rsh" +#include "../../../../scriptc/rs_math.rsh" +#include "../../../../scriptc/rs_graphics.rsh" static int newPart = 0; @@ -12,15 +12,15 @@ typedef struct Control_s { int rate; int count; float r, g, b; - rs_allocation partBuffer; rs_mesh partMesh; + rs_allocation partBuffer; } Control_t; Control_t *Control; typedef struct Point_s{ float2 delta; - float2 position; - unsigned int color; + rs_position2 pos; + rs_color4u color; } Point_t; Point_t *point; @@ -33,8 +33,6 @@ int main(int launchID) { if (rate) { float rMax = ((float)rate) * 0.005f; - int x = Control->x; - int y = Control->y; int color = ((int)(Control->r * 255.f)) | ((int)(Control->g * 255.f)) << 8 | ((int)(Control->b * 255.f)) << 16 | @@ -42,9 +40,11 @@ int main(int launchID) { Point_t * np = &p[newPart]; while (rate--) { - np->delta = vec2Rand(rMax); - np->position.x = x; - np->position.y = y; + np->delta.x = rand(rMax); + np->delta.y = rand(rMax); + //np->delta = vec2Rand(rMax); + np->pos.x = Control->x; + np->pos.y = Control->y; np->color = color; newPart++; np++; @@ -57,13 +57,13 @@ int main(int launchID) { for (ct=0; ct < count; ct++) { float dy = p->delta.y + 0.15f; - float posy = p->position.y + dy; + float posy = p->pos.y + dy; if ((posy > height) && (dy > 0)) { dy *= -0.3f; } p->delta.y = dy; - p->position.x += p->delta.x; - p->position.y = posy; + p->pos.x += p->delta.x; + p->pos.y = posy; p++; } diff --git a/libs/rs/java/ImageProcessing/res/raw/threshold2.rs b/libs/rs/java/ImageProcessing/res/raw/threshold2.rs new file mode 100644 index 0000000..9f687b5 --- /dev/null +++ b/libs/rs/java/ImageProcessing/res/raw/threshold2.rs @@ -0,0 +1,49 @@ +#pragma version(1) + +#include "../../../../scriptc/rs_types.rsh" +#include "../../../../scriptc/rs_math.rsh" +#include "../../../../scriptc/rs_graphics.rsh" + +typedef struct Params_s{ + int inHeight; + int inWidth; + int outHeight; + int outWidth; + float threshold; +} Params_t; + +Params_t * Params; +rs_color4u * InPixel; +rs_color4u * OutPixel; + + +int main() { + int t = uptimeMillis(); + + rs_color4u *in = InPixel; + rs_color4u *out = OutPixel; + + int count = Params->inWidth * Params->inHeight; + int i; + float threshold = Params->threshold * 255.f; + + for (i = 0; i < count; i++) { + float luminance = 0.2125f * in->x + + 0.7154f * in->y + + 0.0721f * in->z; + if (luminance > threshold) { + *out = *in; + } else { + *((int *)out) = *((int *)in) & 0xff000000; + } + + in++; + out++; + } + + t= uptimeMillis() - t; + debugI32("Filter time", t); + + sendToClient(&count, 1, 4, 0); + return 0; +} |
