Tweak the galaxy
diff --git a/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png b/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png
index e1c7010..3a5c970 100644
--- a/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png
+++ b/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png
Binary files differ
diff --git a/libs/rs/java/Galaxy/res/raw/galaxy.c b/libs/rs/java/Galaxy/res/raw/galaxy.c
index 8575712..59c31a1 100644
--- a/libs/rs/java/Galaxy/res/raw/galaxy.c
+++ b/libs/rs/java/Galaxy/res/raw/galaxy.c
@@ -30,7 +30,7 @@
 
 #define PARTICLES_TEXTURES_COUNT 2
 
-#define ELLIPSE_RATIO 0.86f
+#define ELLIPSE_RATIO 0.892f
 #define ELLIPSE_TWIST 0.02333333333f
 
 void drawSpace(int width, int height) {
@@ -47,15 +47,18 @@
 }
 
 void drawLights(int width, int height) {
-    float x = (width - 512.0f) / 2.0f;
-    float y = (height - 512.0f) / 2.0f;
+    float x = (width - 512.0f) * 0.5f;
+    float y = (height - 512.0f) * 0.5f;
+    
+    // increase the size of the texture by 5% on each side
+    x -= 512.0f * 0.05f;
 
     bindProgramFragment(NAMED_PFBackground);
     bindTexture(NAMED_PFBackground, 0, NAMED_TLight1);
-    drawQuad(x + 512.0f, y         , 0.0f,
-             x         , y         , 0.0f,
-             x         , y + 512.0f, 0.0f,
-             x + 512.0f, y + 512.0f, 0.0f);
+    drawQuad(x + 512.0f * 1.1f, y         , 0.0f,
+             x                , y         , 0.0f,
+             x                , y + 512.0f, 0.0f,
+             x + 512.0f * 1.1f, y + 512.0f, 0.0f);
 }
 
 void drawParticle(float *particle, int index, float *particleBuffer, int bufferIndex,
@@ -67,11 +70,11 @@
     float r = particle[index + PARTICLE_STRUCT_RADIUS];
 
     float a = angle + speed;
-    float x = distance * sinf(a);
-    float y = distance * cosf(a) * ELLIPSE_RATIO;
+    float x = distance * sinf_fast(a);
+    float y = distance * cosf_fast(a) * ELLIPSE_RATIO;
     float z = distance * ELLIPSE_TWIST;
-    float s = cosf(z);
-    float t = sinf(z);
+    float s = cosf_fast(z);
+    float t = sinf_fast(z);
 
     float sX = t * x + s * y + w;
     float sY = s * x - t * y + h;
@@ -87,7 +90,7 @@
 
     // upper middle vertex of the particle's triangle
     bufferIndex += PARTICLE_BUFFER_COMPONENTS_COUNT;
-    particleBuffer[bufferIndex + 1] = sX;     // X
+    particleBuffer[bufferIndex + 1] = sX;         // X
     particleBuffer[bufferIndex + 2] = sY - r;     // Y
 
     particle[index + PARTICLE_STRUCT_ANGLE] = a;
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
index 1b9e349..717100d 100644
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
+++ b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
@@ -49,7 +49,6 @@
     private static final int RSID_STATE = 0;
 
     private static final int TEXTURES_COUNT = 3;
-    private static final int PARTICLES_TEXTURES_COUNT = 2;
     private static final int RSID_TEXTURE_SPACE = 0;
     private static final int RSID_TEXTURE_LIGHT1 = 1;
     private static final int RSID_TEXTURE_FLARES = 2;
@@ -216,13 +215,15 @@
 
     @SuppressWarnings({"PointlessArithmeticExpression"})
     private void createParticle(float[] particles, int index, int bufferIndex) {
-        float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f;
+        float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f + random(-4.0f, 4.0f);
+        float z = randomGauss() * 0.5f * 0.8f * ((GALAXY_RADIUS - d) / (float) GALAXY_RADIUS);
+        z += 1.0f;
 
         particles[index + PARTICLE_STRUCT_ANGLE] = random(0.0f, (float) (Math.PI * 2.0));
         particles[index + PARTICLE_STRUCT_DISTANCE] = d;
         particles[index + PARTICLE_STRUCT_SPEED] = random(0.0015f, 0.0025f) *
-                (0.5f + (0.5f * (float) GALAXY_RADIUS / d));
-        particles[index + PARTICLE_STRUCT_RADIUS] = random(1.0f, 2.1f);
+                (0.5f + (0.5f * (float) GALAXY_RADIUS / d)) * 0.7f;
+        particles[index + PARTICLE_STRUCT_RADIUS] = z * random(1.2f, 2.1f);
 
         int red, green, blue;
         if (d < GALAXY_RADIUS / 3.0f) {
@@ -234,27 +235,24 @@
             green = 180;
             blue = (int) constrain(140 + (d / (float) GALAXY_RADIUS) * 115, 140, 255);
         }
-
-        final int color = 0xFF000000 | red | green << 8 | blue << 16;
-        final int sprite = random(PARTICLES_TEXTURES_COUNT);        
-        final float u1 = sprite / (float) PARTICLES_TEXTURES_COUNT;
-        final float u2 = (sprite + 1) / (float) PARTICLES_TEXTURES_COUNT;
+        
+        final int color = red | green << 8 | blue << 16 | 0xff000000;
 
         final float[] floatData = mFloatData5;
         final Allocation buffer = mParticlesBuffer;
         
         floatData[0] = Float.intBitsToFloat(color);
-        floatData[3] = u1;
+        floatData[3] = 0.0f;
         floatData[4] = 1.0f;
         buffer.subData1D(bufferIndex, 1, floatData);
 
         bufferIndex++;
-        floatData[3] = u2;
+        floatData[3] = 1.0f;
         floatData[4] = 1.0f;
         buffer.subData1D(bufferIndex, 1, floatData);
 
         bufferIndex++;
-        floatData[3] = u1 + (u2 - u1) / 2.0f;
+        floatData[3] = 0.5f;
         floatData[4] = 0.0f;
         buffer.subData1D(bufferIndex, 1, floatData);
     }
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 0ecdf9a..5f8ee2a 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -170,6 +170,44 @@
 #define DEG_TO_RAD PI / 180.0f
 #define RAD_TO_DEG 180.0f / PI
 
+static float SC_sinf_fast(float x)
+{
+    const float A =   1.0f / (2.0f * M_PI);
+    const float B = -16.0f;
+    const float C =   8.0f;
+    
+    // scale angle for easy argument reduction
+    x *= A;
+    
+    if (fabsf(x) >= 0.5f) {
+        // argument reduction
+        x = x - ceilf(x + 0.5f) + 1.0f;
+    }
+    
+    const float y = B * x * fabsf(x) + C * x;
+    return 0.2215f * (y * fabsf(y) - y) + y;
+}
+
+static float SC_cosf_fast(float x)
+{
+    x += float(M_PI / 2);
+
+    const float A =   1.0f / (2.0f * M_PI);
+    const float B = -16.0f;
+    const float C =   8.0f;
+    
+    // scale angle for easy argument reduction
+    x *= A;
+    
+    if (fabsf(x) >= 0.5f) {
+        // argument reduction
+        x = x - ceilf(x + 0.5f) + 1.0f;
+    }
+    
+    const float y = B * x * fabsf(x) + C * x;
+    return 0.2215f * (y * fabsf(y) - y) + y;
+}
+
 static float SC_randf(float max)
 {
     float r = (float)rand();
@@ -846,6 +884,10 @@
         "int", "(int)" },
     { "absf", (void *)&fabs,
         "float", "(float)" },
+    { "sinf_fast", (void *)&SC_sinf_fast,
+        "float", "(float)" },
+    { "cosf_fast", (void *)&SC_cosf_fast,
+        "float", "(float)" },
     { "sinf", (void *)&sinf,
         "float", "(float)" },
     { "cosf", (void *)&cosf,