Handwriting animation storage and acquisition-an alternative special effect Animation
The Path animation in the previous article-the animation implementation of writing text introduces some idea of handwriting Animation: record the coordinates of every vertex passing by the pen tip, and then splice these vertices into the path for one step painting, to achieve a graphic effect that allows the mobile phone to automatically draw the image we want, this is to put the path information in the memory, and now implement a persistent layer.
Let's first take a look at the effect. The last one we drew was a finger to let the phone draw. Now this is the mobile phone that automatically draws our text. Of course, we have to prepare the resource for drawing the text.
Vc7EvP6hozwvcD4KPHA + z8i/tM/C0ru49rnYvPy1xLmkvt/fingerprint = "brush: java;">/*** Created by Wood on 2015/2/8. */public class PathHelper {public static void writePath (ArrayList> path, String filaName) {OutputStream out = null; try {out = new FileOutputStream (new File (Environment. getExternalStorageDirectory (), filaName); ObjectOutputStream oos = new ObjectOutputStream (out); oos. writeObject (path);} catch (FileNotFoundException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} finally {try {out. close ();} catch (IOException e) {e. printStackTrace () ;}} Log. I ("info", "saved successfully");} public static ArrayList> read (int rawId, Context context) {InputStream is = context. getResources (). openRawResource (rawId); ArrayList> lines = null; try {ObjectInputStream ois = new ObjectInputStream (is); lines = (ArrayList>) ois. readObject ();} catch (IOException e) {e. printStackTrace ();} catch (ClassNotFoundException e) {e. printStackTrace ();} finally {try {is. close ();} catch (IOException e) {e. printStackTrace () ;}} Log. I ("info", "Read succeeded"); return lines ;}}
The object input/output stream is used. Note that the PathPoint we encapsulate must implement Serializable and cannot be an internal class.
For the method of drawing the path, refer to the previous article. Save the saved file to the raw Resource Directory of the Project. Use this tool class to input the file into the memory and draw it.
This is only an introduction to the Android method. If it inspires some of your ideas, please give me a yes.