Back to project page Sertimus.
The source code is released under:
GNU General Public License
If you think the Android project Sertimus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* Sertimus - A live wallpaper featuring a cute Chao. /*w w w. ja v a 2 s .c o m*/ Copyright (C) 2013 Kevin Negrin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* GrassStrands.java - Object representing strands of a grass whose animation * is tweened through Matrices. */ package gameaddict30.wallpaper.sertimus.objects; import gameaddict30.wallpaper.sertimus.MainCanvas; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; public class GrassStrands extends LiveObject { private final float skewFactor = 0.01f; private final int maxFrames = 20; private int animationTimeline = 0; private Bitmap skewedImage[]; public GrassStrands(MainCanvas c) { super(c, "images/grasstips_optimized.png"); loadImageResource(); // TODO Auto-generated constructor stub x = (int)(Math.random() * (c.getWidth()+1-(width*2))); y = (int)(Math.random() * (c.getHeight()+1-(height*2))); offsetX = -1*(width/2); offsetY = -1*height; } @Override public void updateObject() { animationTimeline++; if (animationTimeline >= maxFrames) animationTimeline = 0; } @Override public void drawObject(Canvas c) { c.drawBitmap(skewedImage[animationTimeline], x-(offsetX+animationTimeline), y+offsetY, null); } public void loadImageResource() { image = Bitmap.createScaledBitmap(image, 64, 64, false); width = image.getWidth(); height = image.getHeight(); skewedImage = new Bitmap[maxFrames]; for (int x=0; x < skewedImage.length; x++) { Matrix manipMat = new Matrix(); manipMat.setSkew(skewFactor*x, 0); skewedImage[x] = Bitmap.createBitmap(image, 0, 0, image.getWidth(), image.getHeight(), manipMat, true); } image.recycle(); } }