summaryrefslogtreecommitdiffstats
path: root/src/com/android/dreams/phototable/PhotoTable.java
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-09-13 13:38:16 -0400
committerChris Wren <cwren@android.com>2012-09-13 13:46:55 -0400
commitf40bfb6272ceec0f3ec471495a8e1b739c5b9d4f (patch)
tree3b6d83a84d9ec8b2790bf83629aaa80d11498afa /src/com/android/dreams/phototable/PhotoTable.java
parent76086400f8e68b810bf1b3db0dc4f7133c8644ae (diff)
downloadandroid_packages_screensavers_PhotoTable-f40bfb6272ceec0f3ec471495a8e1b739c5b9d4f.tar.gz
android_packages_screensavers_PhotoTable-f40bfb6272ceec0f3ec471495a8e1b739c5b9d4f.tar.bz2
android_packages_screensavers_PhotoTable-f40bfb6272ceec0f3ec471495a8e1b739c5b9d4f.zip
multiple landing zones for photo table.
Change-Id: I71592794d73884ce0dd018d72f69a6c200a3f36d
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoTable.java')
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java
index 32d4bf1..32f7bba 100644
--- a/src/com/android/dreams/phototable/PhotoTable.java
+++ b/src/com/android/dreams/phototable/PhotoTable.java
@@ -176,6 +176,20 @@ public class PhotoTable extends FrameLayout {
return p;
}
+ private static PointF randMultiDrop(int n, float i, float j, int width, int height) {
+ log("randMultiDrop (" + n + "," + i + ", " + j + ", " + width + ", " + height + ")");
+ final float[] cx = {0.3f, 0.3f, 0.5f, 0.7f, 0.7f};
+ final float[] cy = {0.3f, 0.7f, 0.5f, 0.3f, 0.7f};
+ n = Math.abs(n);
+ float x = cx[n % cx.length];
+ float y = cy[n % cx.length];
+ PointF p = new PointF();
+ p.x = x * width + 0.05f * width * i;
+ p.y = y * height + 0.05f * height * j;
+ log("randInCenter returning " + p.x + "," + p.y);
+ return p;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
@@ -342,8 +356,9 @@ public class PhotoTable extends FrameLayout {
public void dropOnTable(final View photo, final Interpolator interpolator) {
float angle = randfrange(-mImageRotationLimit, mImageRotationLimit);
- PointF p = randInCenter((float) sRNG.nextGaussian(), (float) sRNG.nextGaussian(),
- mWidth, mHeight);
+ PointF p = randMultiDrop(sRNG.nextInt(),
+ (float) sRNG.nextGaussian(), (float) sRNG.nextGaussian(),
+ mWidth, mHeight);
float x = p.x;
float y = p.y;
@@ -354,8 +369,8 @@ public class PhotoTable extends FrameLayout {
float width = (float) ((Integer) photo.getTag(R.id.photo_width)).intValue();
float height = (float) ((Integer) photo.getTag(R.id.photo_height)).intValue();
- x -= mTableRatio * mLongSide / 2f;
- y -= mTableRatio * mLongSide / 2f;
+ x -= mLongSide / 2f;
+ y -= mShortSide / 2f;
log("fixed offset is " + x + ", " + y);
float dx = x - x0;