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.
/** * StrechOriginalCoverAnimator.java//from w w w .j av a 2 s . c o m * Author: marek.brodziak@gmail.com * Created: Jun 2, 2014 * Copyright 2014 by miniti */ package pl.miniti.android.pleasures.animation; import java.util.ArrayList; import java.util.List; import android.graphics.Matrix; import android.graphics.Path; /** * Horizontal strech of the album cover */ public class StrechOriginalCoverAnimator implements Animator { /** * Controls streching speed */ protected static final float DIFF = .01f; /** * Out of 2f the begining of the magnified part of the animation */ protected static final float MIN = .7f; /** * Out of 2f the end of the magnified part of the animation */ protected static final float MAX = 1.3f; /** * Collection of currently available paths */ protected List<Path> paths = new ArrayList<Path>(); /** * Phase of the animation */ protected float phase = 1f; /** * Translation matrix for the current phase */ protected Matrix phaseMatrix = new Matrix(); /** * Current strech value: positive or negative depending on the animation * phase */ protected float diff = DIFF; /** * No-arg default constructor */ public StrechOriginalCoverAnimator() { paths = OriginalCover.paths(1 - MIN); phaseMatrix.setScale(1f, 1f, .5f, 0f); } /* * (non-Javadoc) * * @see pl.miniti.android.pleasures.animation.Animator#of(int) */ @Override public Path of(int line, int of) { Path copy = new Path(paths.get(line)); copy.transform(phaseMatrix); return copy; } /* * (non-Javadoc) * * @see pl.miniti.android.pleasures.animation.Animator#frame() */ @Override public void frame() { phase += diff; if (phase >= MAX || phase <= MIN) { diff = -diff; } phaseMatrix.setScale(phase, 1f, .5f, 0f); } }