diff options
| -rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain.rs | 14 | ||||
| -rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain_bc.bc | bin | 2924 -> 3000 bytes | |||
| -rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java | 17 | ||||
| -rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 24 | ||||
| -rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java | 5 |
5 files changed, 40 insertions, 20 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain.rs b/libs/rs/java/Fountain/res/raw/fountain.rs index ef12d9accb8d..2ecb3916cb72 100644 --- a/libs/rs/java/Fountain/res/raw/fountain.rs +++ b/libs/rs/java/Fountain/res/raw/fountain.rs @@ -8,7 +8,6 @@ #include "../../../../scriptc/rs_graphics.rsh" static int newPart = 0; -static float4 partColor; rs_mesh partMesh; typedef struct __attribute__((packed, aligned(4))) Point { @@ -40,16 +39,17 @@ int root() { return 1; } -void addParticles(int rate, float x, float y, bool newColor) +static float4 partColor[10]; +void addParticles(int rate, float x, float y, int index, bool newColor) { if (newColor) { - partColor.x = rsRand(0.5f, 1.0f); - partColor.y = rsRand(1.0f); - partColor.z = rsRand(1.0f); + partColor[index].x = rsRand(0.5f, 1.0f); + partColor[index].y = rsRand(1.0f); + partColor[index].z = rsRand(1.0f); } - float rMax = ((float)rate) * 0.005f; + float rMax = ((float)rate) * 0.02f; int size = rsAllocationGetDimX(rsGetAllocation(point)); - uchar4 c = rsPackColorTo8888(partColor); + uchar4 c = rsPackColorTo8888(partColor[index]); Point_t * np = &point[newPart]; float2 p = {x, y}; diff --git a/libs/rs/java/Fountain/res/raw/fountain_bc.bc b/libs/rs/java/Fountain/res/raw/fountain_bc.bc Binary files differindex ac6b7d4e5b0d..822f30ad9c28 100644 --- a/libs/rs/java/Fountain/res/raw/fountain_bc.bc +++ b/libs/rs/java/Fountain/res/raw/fountain_bc.bc diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java index ffe2fad97c3a..c001e842ba85 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java @@ -48,13 +48,20 @@ public class FountainRS { mRS.contextBindRootScript(mScript); } - boolean holdingColor = false; - public void newTouchPosition(int x, int y, int rate) { + boolean holdingColor[] = new boolean[10]; + public void newTouchPosition(float x, float y, float pressure, int id) { + if (id > holdingColor.length) { + return; + } + int rate = (int)(pressure * pressure * 500.f); + if(rate > 500) { + rate = 500; + } if (rate > 0) { - mScript.invoke_addParticles(rate, x, y, !holdingColor); - holdingColor = true; + mScript.invoke_addParticles(rate, x, y, id, !holdingColor[id]); + holdingColor[id] = true; } else { - holdingColor = false; + holdingColor[id] = false; } } diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java index dfd6a49d09a1..6082c1e878a7 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -73,15 +73,27 @@ public class FountainView extends RSSurfaceView { { int act = ev.getAction(); if (act == ev.ACTION_UP) { - mRender.newTouchPosition(0, 0, 0); + mRender.newTouchPosition(0, 0, 0, 0); return false; } - float rate = (ev.getPressure() * 50.f); - rate *= rate; - if(rate > 2000.f) { - rate = 2000.f; + + int count = ev.getHistorySize(); + int pcount = ev.getPointerCount(); + + for (int p=0; p < pcount; p++) { + int id = ev.getPointerId(p); + mRender.newTouchPosition(ev.getX(p), + ev.getY(p), + ev.getPressure(p), + id); + + for (int i=0; i < count; i++) { + mRender.newTouchPosition(ev.getHistoricalX(p, i), + ev.getHistoricalY(p, i), + ev.getHistoricalPressure(p, i), + id); + } } - mRender.newTouchPosition((int)ev.getX(), (int)ev.getY(), (int)rate); return true; } } diff --git a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java index a4c598be46e1..95ce1ab32a99 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/ScriptC_Fountain.java @@ -50,11 +50,12 @@ public class ScriptC_Fountain extends ScriptC { } private final static int mExportFuncIdx_addParticles = 0; - public void invoke_addParticles(int rate, float x, float y, boolean newColor) { - FieldPacker addParticles_fp = new FieldPacker(16); + public void invoke_addParticles(int rate, float x, float y, int index, boolean newColor) { + FieldPacker addParticles_fp = new FieldPacker(20); addParticles_fp.addI32(rate); addParticles_fp.addF32(x); addParticles_fp.addF32(y); + addParticles_fp.addI32(index); addParticles_fp.addBoolean(newColor); addParticles_fp.skip(3); invoke(mExportFuncIdx_addParticles, addParticles_fp); |