Back to project page unknown-pleasures.
The source code is released under:
Creative Commons Attribution NonCommercial NoDerivs (CC-NC-ND) THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTE...
If you think the Android project unknown-pleasures listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * HorizontalOriginalCoverAnimator.java/*w ww . j a v a 2s .c o m*/ * Author: marek.brodziak@gmail.com * Created: Jun 2, 2014 * Copyright 2014 by miniti */ package pl.miniti.android.pleasures.animation; import android.graphics.Path; /** * Horizontal scroll of the original cover */ public class HorizontalScrollAnimator implements Animator { /** * Randomly initialized y peaks */ protected float[][] peeks = new float[OriginalCover.SIZE][]; /** * Current phase of the animation */ protected int shift = 0; /** * Number of y peaks in each line */ protected int count; /** * No-arg default constructor */ public HorizontalScrollAnimator() { for (int i = 0; i < OriginalCover.SIZE; ++i) { peeks[i] = AnimatorUtil.randomPeeks(); } count = peeks[0].length; } /* * (non-Javadoc) * * @see pl.miniti.android.pleasures.animation.Animator#of(int, int) */ @Override public Path of(int line, int of) { Path p = new Path(); float[] ps = peeks[line]; p.moveTo(0f, ps[shift]); for (int i = 1; i < count; ++i) { int index = shift + i; index = index >= count ? index - count : index; final float x = i * AnimatorUtil.RESOLUTION; float distance = x - .5f; distance = distance > 0 ? distance : -distance; final float raiser = (distance > .25f) ? 1f : (35f - (distance * 150f)); p.lineTo(x, -Math.abs(ps[index]) * (raiser > 1f ? raiser : 1f)); } return p; } /* * (non-Javadoc) * * @see pl.miniti.android.pleasures.animation.Animator#frame() */ @Override public void frame() { ++shift; if (shift == count) { shift = 0; } } }