Handwriting animation storage and acquisition-an alternative special effect Animation

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.