float skyOffsetX;
float skyOffsetY;
+int lastDrop;
+
struct vert_s {
float x;
float y;
}
void initLeaves() {
+ if (State->isPreview) lastDrop = uptimeMillis();
+
struct Leaves_s *leaf = Leaves;
int leavesCount = State->leavesCount;
+ float width = State->glWidth;
float height = State->glHeight;
int i;
for (i = 0; i < leavesCount; i ++) {
int sprite = randf(LEAVES_TEXTURES_COUNT);
- leaf->x = randf2(-1.0f, 1.0f);
- leaf->y = randf2(-height / 2.0f, height / 2.0f);
+ leaf->x = randf2(-width * 0.5f, width * 0.5f);
+ leaf->y = randf2(-height * 0.5f, height * 0.5f);
leaf->scale = randf2(0.4f, 0.5f);
leaf->angle = randf2(0.0f, 360.0f);
- leaf->spin = degf(randf2(-0.02f, 0.02f)) / 4.0f;
+ leaf->spin = degf(randf2(-0.02f, 0.02f)) * 0.25f;
leaf->u1 = sprite / (float) LEAVES_TEXTURES_COUNT;
leaf->u2 = (sprite + 1) / (float) LEAVES_TEXTURES_COUNT;
leaf->altitude = -1.0f;
LEAF_SIZE * s + y < -glHeight / 2.0f) {
int sprite = randf(LEAVES_TEXTURES_COUNT);
- leaf->x = randf2(-1.0f, 1.0f);
- leaf->y = randf2(-glHeight / 2.0f, glHeight / 2.0f);
+ leaf->x = randf2(-glWidth * 0.5f, glWidth * 0.5f);
+ leaf->y = randf2(-glHeight * 0.5f, glHeight * 0.5f);
leaf->scale = randf2(0.4f, 0.5f);
- leaf->spin = degf(randf2(-0.02f, 0.02f)) / 4.0f;
+ leaf->spin = degf(randf2(-0.02f, 0.02f)) * 0.25f;
leaf->u1 = sprite / (float) LEAVES_TEXTURES_COUNT;
leaf->u2 = (sprite + 1) / (float) LEAVES_TEXTURES_COUNT;
leaf->altitude = 0.6f;
Drop->dropX = -1;
Drop->dropY = -1;
}
+
+ if (State->isPreview) {
+ int now = uptimeMillis();
+ if (now - lastDrop > 2000) {
+ float x = randf(State->meshWidth);
+ float y = randf(State->meshHeight);
+
+ drop(x, y, DROP_RADIUS);
+
+ lastDrop = now;
+ }
+ }
updateRipples();
generateRipples();
#define REAL_TIME 1
-float time() {
- if (REAL_TIME) {
+float time(int isPreview) {
+ if (REAL_TIME && !isPreview) {
return (hour() * 3600.0f + minute() * 60.0f + second()) / SECONDS_IN_DAY;
}
- float t = uptimeMillis() / 40000.0f;
+ float t = uptimeMillis() / 30000.0f;
return t - (int) t;
}
}
int drawBlade(float *bladeStruct, float *bladeBuffer, int *bladeColor,
- float brightness, float xOffset) {
+ float brightness, float xOffset, float now) {
float offset = bladeStruct[BLADE_STRUCT_OFFSET];
float scale = bladeStruct[BLADE_STRUCT_SCALE];
int color = hsbToAbgr(h, s, lerpf(0, b, brightness), 1.0f);
- float newAngle = turbulencef2(turbulenceX, uptimeMillis() * 0.00004f, 4.0f) - 0.5f;
- newAngle *= 0.5f;
+ float newAngle = (turbulencef2(turbulenceX, now, 4.0f) - 0.5f) * 0.5f;
angle = clampf(angle + (newAngle + offset - angle) * 0.15f, -MAX_BEND, MAX_BEND);
float currentAngle = HALF_PI;
float *bladeStruct = loadArrayF(RSID_BLADES, 0);
float *bladeBuffer = loadArrayF(RSID_BLADES_BUFFER, 0);
int *bladeColor = loadArrayI32(RSID_BLADES_BUFFER, 0);
+
+ float now = uptimeMillis() * 0.00004f;
for ( ; i < bladesCount; i += 1) {
- int offset = drawBlade(bladeStruct, bladeBuffer, bladeColor, brightness, xOffset);
+ int offset = drawBlade(bladeStruct, bladeBuffer, bladeColor, brightness, xOffset, now);
bladeBuffer += offset;
bladeColor += offset;
bladeStruct += BLADE_STRUCT_FIELDS_COUNT;
float x = lerpf(width, 0, State->xOffset);
- float now = time();
+ float now = time(State->isPreview);
alpha(1.0f);
float newB = 1.0f;
<!-- about the fall wallpaper. -->
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
-/>
+ android:thumbnail="@drawable/water_thumb" />
<!-- about the galaxy wallpaper. -->
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
-/>
+ android:thumbnail="@drawable/galaxy_thumb" />
\ No newline at end of file
<!-- about the grass wallpaper. -->
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
-/>
+ android:thumbnail="@drawable/grass_thumb" />
<!-- about the polar clock. -->
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
- android:thumbnail="@drawable/polarclock_thumb"
- android:settingsActivity="com.android.wallpaper.polarclock.PolarClockSettings"
-/>
+ android:thumbnail="@drawable/polarclock_thumb"
+ android:settingsActivity="com.android.wallpaper.polarclock.PolarClockSettings" />
public float skySpeedX;
public float skySpeedY;
public int rotate;
+ public int isPreview;
}
static class DropState {
mWorldState.skySpeedX = random(-0.001f, 0.001f);
mWorldState.skySpeedY = random(0.00008f, 0.0002f);
mWorldState.rotate = mWidth > mHeight ? 1 : 0;
+ mWorldState.isPreview = isPreview() ? 1 : 0;
mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState");
mState = Allocation.createTyped(mRS, mStateType);
public float morning;
public float afternoon;
public float dusk;
+ public int isPreview;
}
private void createState() {
+ final boolean isPreview = isPreview();
+
mWorldState = new WorldState();
mWorldState.width = mWidth;
mWorldState.height = mHeight;
mWorldState.bladesCount = BLADES_COUNT;
mWorldState.trianglesCount = mTriangles;
+ mWorldState.isPreview = isPreview ? 1 : 0;
+ if (isPreview) {
+ mWorldState.xOffset = 0.5f;
+ }
mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState");
mState = Allocation.createTyped(mRS, mStateType);
import android.os.SystemClock;
import android.text.format.Time;
import android.util.MathUtils;
+import android.util.Log;
import java.util.HashMap;
import java.util.TimeZone;
import com.android.wallpaper.R;
public class PolarClockWallpaper extends WallpaperService {
- public static final String SHARED_PREFS_NAME = "polar_clock_settings";
+ private static final String LOG_TAG = "PolarClock";
+
+ static final String SHARED_PREFS_NAME = "polar_clock_settings";
- public static final String PREF_SHOW_SECONDS = "show_seconds";
- public static final String PREF_VARIABLE_LINE_WIDTH = "variable_line_width";
- public static final String PREF_PALETTE = "palette";
+ static final String PREF_SHOW_SECONDS = "show_seconds";
+ static final String PREF_VARIABLE_LINE_WIDTH = "variable_line_width";
+ static final String PREF_PALETTE = "palette";
- public static final int BACKGROUND_COLOR = 0xffffffff;
+ static final int BACKGROUND_COLOR = 0xffffffff;
static abstract class ClockPalette {
public static ClockPalette parseXmlPaletteTag(XmlResourceParser xrp) {
return new ClockEngine();
}
- class ClockEngine extends Engine
- implements SharedPreferences.OnSharedPreferenceChangeListener {
+ class ClockEngine extends Engine implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final float SMALL_RING_THICKNESS = 8.0f;
private static final float MEDIUM_RING_THICKNESS = 16.0f;
private static final float LARGE_RING_THICKNESS = 32.0f;
what = xrp.next();
}
} catch (IOException e) {
- // XXX: Log?
+ Log.e(LOG_TAG, "An error occured during wallpaper configuration:", e);
} catch (XmlPullParserException e) {
- // XXX: Log?
+ Log.e(LOG_TAG, "An error occured during wallpaper configuration:", e);
} finally {
xrp.close();
}
paint.setStrokeWidth(DEFAULT_RING_THICKNESS);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.STROKE);
+
+ if (isPreview()) {
+ mOffsetX = 0.5f;
+ }
}
@Override
void drawFrame() {
if (mPalette == null) {
- android.util.Log.w("PolarClockWallpaper", "no palette?!");
+ Log.w("PolarClockWallpaper", "no palette?!");
return;
}