├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── martin
│ │ └── pathdraw
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── martin
│ │ │ └── pathdraw
│ │ │ ├── AfterFillAct.java
│ │ │ ├── FillAct.java
│ │ │ ├── MainActivity.java
│ │ │ └── NormalAct.java
│ └── res
│ │ ├── drawable
│ │ └── nancy.png
│ │ ├── layout
│ │ ├── activity_after_fill.xml
│ │ ├── activity_fill.xml
│ │ ├── activity_main.xml
│ │ └── activity_normal.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── raw
│ │ ├── ironman.svg
│ │ ├── monitor.svg
│ │ ├── nancy.svg
│ │ ├── nancypath1.svg
│ │ ├── nancypath2.svg
│ │ ├── nancypath3.svg
│ │ ├── woman1.svg
│ │ └── woman2.svg
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── martin
│ └── pathdraw
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pdmaster
├── .gitignore
├── build.gradle
├── libs
│ └── androidsvg-1.2.1.jar
├── pathview.md
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── martin
│ │ └── pdmaster
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── martin
│ │ │ └── pdmaster
│ │ │ ├── PathDrawingView.java
│ │ │ └── PathUtils.java
│ └── res
│ │ ├── drawable
│ │ └── mypaint.png
│ │ └── values
│ │ ├── strings.xml
│ │ └── sttr.xml
│ └── test
│ └── java
│ └── com
│ └── martin
│ └── pdmaster
│ └── ExampleUnitTest.java
├── resources
├── afterfill.gif
├── ironman.gif
├── nancy.gif
└── woman.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | PathDraw
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
25 |
26 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PathDraw
2 | It`s a android animation that drawing with svg .
3 |
4 | **Thanks [https://github.com/geftimov/android-pathview](https://github.com/geftimov/android-pathview)**
5 |
6 | this library is base on [android-pathview](https://github.com/geftimov/android-pathview)
7 |
8 | I removed the parallel animation and modified the fill animation .it will be like that:
9 |
10 | 
11 |
12 | ## **sttr:**
13 | ```
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ```
22 | ## **Three modes**
23 |
24 | ### 1.NORMAL
25 |
26 | 
27 |
28 | add the code in your xml:
29 | ```
30 |
36 | ```
37 | ### 2.FILL
38 |
39 | 
40 |
41 | add the code in your xml:
42 | ```
43 |
52 | ```
53 | ### 3.AFTER FILL
54 |
55 | 
56 |
57 | add the code in your xml:
58 | ```
59 |
67 | ```
68 |
69 | ## There is only sequential animation in this library
70 | ```
71 | pathDrawingView.getSequentialPathAnimator().delay(200).duration(5000).start();
72 | ```
73 |
74 | ## **ADD THE LIBRARY **
75 |
76 | Add it in your root build.gradle at the end of repositories:
77 |
78 | allprojects {
79 | repositories {
80 | ...
81 | maven { url "https://jitpack.io" }
82 | }
83 | }
84 | Step 2. Add the dependency
85 |
86 | dependencies {
87 | compile 'com.github.MartinBZDQSM:PathDraw:1.1'
88 | }
89 |
90 | ##[BLOG](http://www.jianshu.com/p/75a83ad1ab7e)
91 |
92 | ##**License**
93 |
94 | ```license
95 | Copyright [2016] [MartinBZDQSM of copyright owner]
96 |
97 | Licensed under the Apache License, Version 2.0 (the "License");
98 | you may not use this file except in compliance with the License.
99 | You may obtain a copy of the License at
100 |
101 | http://www.apache.org/licenses/LICENSE-2.0
102 |
103 | Unless required by applicable law or agreed to in writing, software
104 | distributed under the License is distributed on an "AS IS" BASIS,
105 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
106 | See the License for the specific language governing permissions and
107 | limitations under the License.
108 | ```
109 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.martin.pathdraw"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.4.0'
26 | compile project(':pdmaster')
27 | }
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/martin/pathdraw/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/martin/pathdraw/AfterFillAct.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import com.martin.pdmaster.PathDrawingView;
8 |
9 | public class AfterFillAct extends AppCompatActivity {
10 | private PathDrawingView pathDrawingView;
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_after_fill);
16 | pathDrawingView = (PathDrawingView) findViewById(R.id.pathdrawing);
17 | pathDrawingView.setOnClickListener(new View.OnClickListener() {
18 | @Override
19 | public void onClick(View v) {
20 | pathDrawingView.getSequentialPathAnimator().delay(200).duration(5000).start();
21 | }
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/martin/pathdraw/FillAct.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import com.martin.pdmaster.PathDrawingView;
8 |
9 | public class FillAct extends AppCompatActivity {
10 | private PathDrawingView pathDrawingView;
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_fill);
15 | pathDrawingView = (PathDrawingView) findViewById(R.id.pathdrawing);
16 | pathDrawingView.setOnClickListener(new View.OnClickListener() {
17 | @Override
18 | public void onClick(View v) {
19 | pathDrawingView.getSequentialPathAnimator().delay(200).duration(10000).start();
20 | }
21 | });
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/martin/pathdraw/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 | findViewById(R.id.button).setOnClickListener(onClickListener);
15 | findViewById(R.id.button2).setOnClickListener(onClickListener);
16 | findViewById(R.id.button3).setOnClickListener(onClickListener);
17 | }
18 |
19 |
20 | View.OnClickListener onClickListener = new View.OnClickListener() {
21 | @Override
22 | public void onClick(View v) {
23 | Intent intent = null;
24 | switch (v.getId()) {
25 | case R.id.button:
26 | intent = new Intent(MainActivity.this, NormalAct.class);
27 | break;
28 | case R.id.button2:
29 | intent = new Intent(MainActivity.this, FillAct.class);
30 | break;
31 | case R.id.button3:
32 | intent = new Intent(MainActivity.this, AfterFillAct.class);
33 | break;
34 | }
35 | if (intent != null)
36 | MainActivity.this.startActivity(intent);
37 | }
38 | };
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/martin/pathdraw/NormalAct.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import com.martin.pdmaster.PathDrawingView;
8 |
9 | public class NormalAct extends AppCompatActivity {
10 | private PathDrawingView pathDrawingView;
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_normal);
16 | pathDrawingView = (PathDrawingView) findViewById(R.id.pathdrawing);
17 | pathDrawingView.setOnClickListener(new View.OnClickListener() {
18 | @Override
19 | public void onClick(View v) {
20 | pathDrawingView.getSequentialPathAnimator().delay(200).duration(5000).start();
21 | }
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/nancy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/drawable/nancy.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_after_fill.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_fill.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
22 |
23 |
30 |
31 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/raw/ironman.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/monitor.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/nancypath1.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
193 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/nancypath2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
422 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/woman1.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
187 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/woman2.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
187 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PathDraw
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/martin/pathdraw/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.martin.pathdraw;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.1.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Sep 07 19:49:08 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/pdmaster/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/pdmaster/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.4.0'
25 | }
26 |
--------------------------------------------------------------------------------
/pdmaster/libs/androidsvg-1.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/pdmaster/libs/androidsvg-1.2.1.jar
--------------------------------------------------------------------------------
/pdmaster/pathview.md:
--------------------------------------------------------------------------------
1 | ## android-pathview
2 |
3 | [](https://gitter.im/geftimov/android-pathview?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://android-arsenal.com/details/1/1421) [](https://maven-badges.herokuapp.com/maven-central/com.eftimoff/android-pathview)
4 |
5 | You want to animate svg or normal Paths?
6 | Change the color, pathWidth or add svg.
7 | Animate the "procentage" property to make the animation.
8 |
9 | ### There are two types of paths :
10 |
11 | #### 1. From Svg
12 | ```xml
13 |
21 | ```
22 |
23 | Result
24 |
25 | 
26 |
27 | #### 2. From Path
28 | ```xml
29 |
36 | ```
37 |
38 | In Code
39 |
40 | ```java
41 | final Path path = new Path();
42 | path.moveTo(0.0f, 0.0f);
43 | path.lineTo(length / 4f, 0.0f);
44 | path.lineTo(length, height / 2.0f);
45 | path.lineTo(length / 4f, height);
46 | path.lineTo(0.0f, height);
47 | path.lineTo(length * 3f / 4f, height / 2f);
48 | path.lineTo(0.0f, 0.0f);
49 | path.close();
50 |
51 | pathView.setPath(path);
52 | ```
53 |
54 | Result
55 |
56 | 
57 |
58 | #### Use the animator for parallel animation
59 | ```java
60 | pathView.getPathAnimator()
61 | .delay(100)
62 | .duration(500)
63 | .listenerStart(new AnimationListenerStart())
64 | .listenerEnd(new AnimationListenerEnd())
65 | .interpolator(new AccelerateDecelerateInterpolator())
66 | .start();
67 | ```
68 |
69 | #### Use the animator for sequential animation
70 | ```java
71 | pathView.getSequentialPathAnimator()
72 | .delay(100)
73 | .duration(500)
74 | .listenerStart(new AnimationListenerStart())
75 | .listenerEnd(new AnimationListenerEnd())
76 | .interpolator(new AccelerateDecelerateInterpolator())
77 | .start();
78 | ```
79 | #### If you want to use the svg colors.
80 | ```java
81 | pathView.useNaturalColors();
82 | ```
83 | #### If you want to draw the real SVG after the path animation.
84 | It is in still in development.
85 | ```java
86 | pathView.setFillAfter(true);
87 | ```
88 | 
89 |
90 | #### TODO
91 |
92 | 1. Make persistent "percentage" field on orientation change.
93 |
94 | ##### Limitations
95 |
96 | When working with SVGs you can not WRAP_CONTENT your views.
97 |
98 | ##### Used in apps
99 |
100 | * https://play.google.com/store/apps/details?id=com.eftimoff.fonts
101 |
102 | Message me if you want to be included in this list.
103 |
104 | ##### Thanks to
105 |
106 | * https://github.com/romainguy/road-trip
107 | * http://www.curious-creature.com/2013/12/21/android-recipe-4-path-tracing/
108 | * https://github.com/matthewrkula/AnimatedPathView
109 |
110 | ##### Contributors
111 |
112 | I want to update this library and make it better. So any help will be appreciated.
113 | Make and pull - request and we can discuss it.
114 |
115 | ##### Download
116 | ```groovy
117 | dependencies {
118 | compile 'com.eftimoff:android-pathview:1.0.8@aar'
119 | }
120 | ```
121 | ##### Changelog
122 |
123 | 1.0.8
124 |
125 | [Fix] Removed not properly used android:allowBackup.
126 |
127 | 1.0.7
128 |
129 | [Feature] Sequential path animation.
130 | [Fix] Use dimensions instead of float for pathWidth.
131 |
132 | ##### Licence
133 |
134 | Copyright 2016 Georgi Eftimov
135 |
136 | Licensed under the Apache License, Version 2.0 (the "License");
137 | you may not use this file except in compliance with the License.
138 | You may obtain a copy of the License at
139 |
140 | http://www.apache.org/licenses/LICENSE-2.0
141 |
142 | Unless required by applicable law or agreed to in writing, software
143 | distributed under the License is distributed on an "AS IS" BASIS,
144 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145 | See the License for the specific language governing permissions and
146 | limitations under the License.
147 |
--------------------------------------------------------------------------------
/pdmaster/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/pdmaster/src/androidTest/java/com/martin/pdmaster/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.martin.pdmaster;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/pdmaster/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pdmaster/src/main/java/com/martin/pdmaster/PathDrawingView.java:
--------------------------------------------------------------------------------
1 | package com.martin.pdmaster;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.content.Context;
6 | import android.content.res.Resources;
7 | import android.content.res.TypedArray;
8 | import android.graphics.Bitmap;
9 | import android.graphics.BitmapFactory;
10 | import android.graphics.Canvas;
11 | import android.graphics.Color;
12 | import android.graphics.Paint;
13 | import android.graphics.Path;
14 | import android.graphics.PointF;
15 | import android.graphics.RectF;
16 | import android.util.AttributeSet;
17 | import android.view.View;
18 | import android.view.animation.Interpolator;
19 |
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | /**
24 | * This class is base on PathView.class in PathView ,
25 | * If you want know more , The link of PathView: https://github.com/geftimov/android-pathview.
26 | *
27 | * Licence of pathview :
28 | *
29 | * Copyright 2016 Georgi Eftimov
30 | * Licensed under the Apache License, Version 2.0 (the "License");
31 | * you may not use this file except in compliance with the License.
32 | * You may obtain a copy of the License at
33 | *
34 | * http://www.apache.org/licenses/LICENSE-2.0
35 | *
36 | * Unless required by applicable law or agreed to in writing, software
37 | * distributed under the License is distributed on an "AS IS" BASIS,
38 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39 | * See the License for the specific language governing permissions and
40 | * limitations under the License.
41 | *
42 | *
43 | * 作者:MartinBZDQSM on 2016/8/28 0028.
44 | * 博客:http://www.jianshu.com/users/78f0e5f4a403/latest_articles
45 | * github:https://github.com/MartinBZDQSM
46 | */
47 | public class PathDrawingView extends View implements PathUtils.AnimationStepListener {
48 |
49 | private static final String TAG = "PathDrawingView";
50 |
51 | //组件的宽高
52 | private int width;
53 | private int height;
54 |
55 | // private Bitmap drawLayer;//需要最后显示的图层,绘制在底部
56 | // private int drawLayerId;
57 | private Paint drawerPaint;
58 | private float nibPrecent = 0.2069f;//笔尖在paintLayer中高的比例
59 | private PointF nibPointf;
60 |
61 | private Bitmap paintLayer;//画笔的图层
62 |
63 | private Paint pathPaint;
64 | private int pathId;
65 | private PathUtils pathLayer = new PathUtils();
66 | private List mPaths = new ArrayList<>();
67 |
68 | private Thread mLoader;
69 | private final Object mSvgLock = new Object();
70 | public static boolean isDrawing = false;
71 |
72 | private boolean isDrawPaint;
73 |
74 | private int defaultColor = Color.GRAY;
75 | private int paintColor;
76 |
77 | private boolean isFill = true;
78 | private RectF drawRect = new RectF();
79 |
80 | private boolean isFillAfter = false;
81 | public static boolean isDrawingFinished = false;
82 |
83 | /**
84 | * 去除了并行动画,采用顺序动画
85 | */
86 | private AnimatorSetBuilder animatorSetBuilder;
87 |
88 | public PathDrawingView(Context context) {
89 | this(context, null);
90 | }
91 |
92 | public PathDrawingView(Context context, AttributeSet attrs) {
93 | super(context, attrs);
94 | getSrcFromAttrs(context, attrs);
95 | }
96 |
97 | private void getSrcFromAttrs(Context context, AttributeSet attrs) {
98 | final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PathDrawingView);
99 | try {
100 | if (a != null) {
101 | pathId = a.getResourceId(R.styleable.PathDrawingView_path, 0);
102 | // drawLayerId = a.getResourceId(R.styleable.PathDrawingView_drawer, 0);
103 | isDrawPaint = a.getBoolean(R.styleable.PathDrawingView_draw_paint, true);
104 | isFillAfter = a.getBoolean(R.styleable.PathDrawingView_fill_after, false);
105 | isFill = a.getBoolean(R.styleable.PathDrawingView_filling, false);
106 | paintColor = a.getColor(R.styleable.PathDrawingView_paint_color, defaultColor);
107 |
108 | pathPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
109 | pathPaint.setStyle(Paint.Style.STROKE);//与这里没有毛关系了
110 | pathPaint.setColor(paintColor);
111 | if (isFill) {
112 | drawerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
113 | drawerPaint.setStyle(Paint.Style.FILL);
114 | drawerPaint.setColor(paintColor);
115 | }
116 | }
117 | } finally {
118 | if (a != null) {
119 | a.recycle();
120 | }
121 | invalidate();
122 | }
123 | }
124 |
125 | @Override
126 | protected void onDraw(Canvas canvas) {
127 | super.onDraw(canvas);
128 | int sc = canvas.save(Canvas.ALL_SAVE_FLAG);
129 | synchronized (mSvgLock) {
130 | int count = mPaths.size();
131 | for (int i = 0; i < count; i++) {
132 | int pc = canvas.save(Canvas.ALL_SAVE_FLAG);
133 | PathUtils.SvgPath svgPath = mPaths.get(i);
134 | if (isFill) {
135 | //需要备用一个完整的path路径,来修复pathPaint的Fill造成绘制过度
136 | Path path = pathLayer.mDrawer.get(i);
137 | canvas.clipPath(path);
138 | //获取svgPath当前矩阵
139 | svgPath.path.computeBounds(drawRect, true);
140 | canvas.drawRect(drawRect, drawerPaint);
141 | }
142 | canvas.drawPath(svgPath.path, pathPaint);
143 | canvas.restoreToCount(pc);
144 | }
145 | }
146 | canvas.restoreToCount(sc);
147 | if (isDrawingFinished && isFillAfter)
148 | pathLayer.drawSvgAfter(canvas, width, height);
149 |
150 | if (isDrawPaint) {
151 | for (PathUtils.SvgPath svgPath : mPaths) {
152 | if (isDrawing && svgPath.isMeasure) {
153 | canvas.drawBitmap(paintLayer, svgPath.point[0] - nibPointf.x, svgPath.point[1] - nibPointf.y, null);
154 | }
155 | }
156 | }
157 | }
158 |
159 | @Override
160 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
161 | super.onLayout(changed, left, top, right, bottom);
162 | }
163 |
164 | @Override
165 | protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
166 | super.onSizeChanged(w, h, oldw, oldh);
167 | if (mLoader != null) {
168 | try {
169 | mLoader.join();
170 | } catch (InterruptedException e) {
171 | }
172 | }
173 | if (pathId != 0) {
174 | mLoader = new Thread(new Runnable() {
175 | @Override
176 | public void run() {
177 | pathLayer.load(getContext(), pathId);
178 | Resources resources = getContext().getResources();
179 | BitmapFactory.Options options = new BitmapFactory.Options();
180 | options.inScaled = false;//获取真实宽高的Paintlayer
181 | paintLayer = BitmapFactory.decodeResource(resources, R.drawable.mypaint, options);
182 |
183 |
184 | // drawLayer = BitmapFactory.decodeResource(resources, drawLayerId, options);
185 | synchronized (mSvgLock) {//同步锁
186 | width = w - getPaddingLeft() - getPaddingRight();
187 | height = h - getPaddingTop() - getPaddingBottom();
188 | //需要测量path
189 | mPaths = pathLayer.getPathsForViewport(width, height);
190 | //画笔 的笔尖位置
191 | float nibX = 0;
192 | float nibY = paintLayer.getHeight() * nibPrecent;
193 | nibPointf = new PointF(nibX, nibY);
194 | }
195 | }
196 | }, "SVG Loader");
197 | mLoader.start();
198 | }
199 | }
200 |
201 |
202 | /**
203 | * AnimatorSet for the paths of the view to be animated one after the other.
204 | *
205 | * @return The AnimatorBuilder to build the animation.
206 | */
207 | public AnimatorSetBuilder getSequentialPathAnimator() {
208 | if (animatorSetBuilder == null) {
209 | animatorSetBuilder = new AnimatorSetBuilder(this);
210 | }
211 | return animatorSetBuilder;
212 | }
213 |
214 |
215 | @Override
216 | public void onAnimationStep() {
217 | invalidate();
218 | }
219 |
220 | /**
221 | * Object for building the sequential animation of the paths of this view.
222 | */
223 | public static class AnimatorSetBuilder {
224 | /**
225 | * Duration of the animation.
226 | */
227 | private int duration;
228 |
229 | private final List durations = new ArrayList<>();
230 |
231 | /**
232 | * Interpolator for the time of the animation.
233 | */
234 | private Interpolator interpolator;
235 | /**
236 | * The delay before the animation.
237 | */
238 | private int delay = 0;
239 | /**
240 | * List of ObjectAnimator that constructs the animations of each path.
241 | */
242 | private final List animators = new ArrayList<>();
243 | /**
244 | * Listener called before the animation.
245 | */
246 | private ListenerStart listenerStart;
247 | /**
248 | * Listener after the animation.
249 | */
250 | private ListenerEnd animationEnd;
251 | /**
252 | * Animation listener.
253 | */
254 | private PathViewAnimatorListener pathViewAnimatorListener;
255 | /**
256 | * The list of paths to be animated.
257 | */
258 | private List paths;
259 |
260 | private int index = 0;
261 | private float totalLenth;
262 |
263 | /**
264 | * Default constructor.
265 | *
266 | * @param pathView The view that must be animated.
267 | */
268 | public AnimatorSetBuilder(final PathDrawingView pathView) {
269 | paths = pathView.mPaths;
270 | for (PathUtils.SvgPath path : paths) {
271 | path.setAnimationStepListener(pathView);
272 | ObjectAnimator animation = ObjectAnimator.ofFloat(path, "length", 0.0f, path.getLength());
273 | totalLenth = totalLenth + path.getLength();
274 | animators.add(animation);
275 | }
276 | }
277 |
278 | /**
279 | * Sets the duration of the animation. Since the AnimatorSet sets the duration for each
280 | * Animator, we have to divide it by the number of paths.
281 | *
282 | * @param duration - The duration of the animation.
283 | * @return AnimatorSetBuilder.
284 | */
285 | public AnimatorSetBuilder duration(final int duration) {
286 | this.duration = duration;
287 | return this;
288 | }
289 |
290 | /**
291 | * Set the Interpolator.
292 | *
293 | * @param interpolator - Interpolator.
294 | * @return AnimatorSetBuilder.
295 | */
296 | public AnimatorSetBuilder interpolator(final Interpolator interpolator) {
297 | this.interpolator = interpolator;
298 | return this;
299 | }
300 |
301 | /**
302 | * The delay before the animation.
303 | *
304 | * @param delay - int the delay
305 | * @return AnimatorSetBuilder.
306 | */
307 | public AnimatorSetBuilder delay(final int delay) {
308 | this.delay = delay;
309 | return this;
310 | }
311 |
312 | /**
313 | * Set a listener before the start of the animation.
314 | *
315 | * @param listenerStart an interface called before the animation
316 | * @return AnimatorSetBuilder.
317 | */
318 | public AnimatorSetBuilder listenerStart(final ListenerStart listenerStart) {
319 | this.listenerStart = listenerStart;
320 | return this;
321 | }
322 |
323 | /**
324 | * Set a listener after of the animation.
325 | *
326 | * @param animationEnd an interface called after the animation
327 | * @return AnimatorSetBuilder.
328 | */
329 | public AnimatorSetBuilder listenerEnd(final ListenerEnd animationEnd) {
330 | this.animationEnd = animationEnd;
331 | return this;
332 | }
333 |
334 | /**
335 | * Starts the animation.
336 | */
337 | public void start() {
338 | if (pathViewAnimatorListener == null) {
339 | pathViewAnimatorListener = new PathViewAnimatorListener();
340 | for (int i = 0; i < paths.size(); i++) {
341 | long animationDuration = (long) (paths.get(i).getLength() * duration / totalLenth);
342 | Animator animator = animators.get(i);
343 | animator.setStartDelay(delay);
344 | animator.setDuration(animationDuration);
345 | animator.addListener(pathViewAnimatorListener);
346 | }
347 | }
348 |
349 | resetAllPaths();
350 | for (Animator animator : animators) {
351 | animator.cancel();
352 | }
353 | index = 0;
354 | startAnimatorByIndex();
355 | }
356 |
357 | public void startAnimatorByIndex() {
358 | if (index >= paths.size()) {
359 | return;
360 | }
361 | Animator animator = animators.get(index);
362 | animator.start();
363 | }
364 |
365 | /**
366 | * Sets the length of all the paths to 0.
367 | */
368 | private void resetAllPaths() {
369 | for (PathUtils.SvgPath path : paths) {
370 | path.setLength(0);
371 | }
372 | }
373 |
374 | /**
375 | * Called when the animation start.
376 | */
377 | public interface ListenerStart {
378 | /**
379 | * Called when the path animation start.
380 | */
381 | void onAnimationStart();
382 | }
383 |
384 | /**
385 | * Called when the animation end.
386 | */
387 | public interface ListenerEnd {
388 | /**
389 | * Called when the path animation end.
390 | */
391 | void onAnimationEnd();
392 | }
393 |
394 | /**
395 | * Animation listener to be able to provide callbacks for the caller.
396 | */
397 | private class PathViewAnimatorListener implements Animator.AnimatorListener {
398 |
399 | @Override
400 | public void onAnimationStart(Animator animation) {
401 | if (index < paths.size() - 1) {
402 | paths.get(index).isMeasure = true;
403 | if (animators.get(index).getDuration() < 50) {//过滤动画事件小于100ms的画笔轨迹
404 | PathDrawingView.isDrawing = false;
405 | } else {
406 | PathDrawingView.isDrawing = true;
407 | }
408 | PathDrawingView.isDrawingFinished = false;
409 | if (index == 0 && listenerStart != null)
410 | listenerStart.onAnimationStart();
411 | }
412 |
413 | }
414 |
415 | @Override
416 | public void onAnimationEnd(Animator animation) {
417 | if (index >= paths.size() - 1) {
418 | PathDrawingView.isDrawing = false;
419 | PathDrawingView.isDrawingFinished = true;
420 | if (animationEnd != null) {
421 | animationEnd.onAnimationEnd();
422 | }
423 | } else {
424 | if (index < paths.size() - 1) {
425 | paths.get(index).isMeasure = false;
426 | index++;
427 | startAnimatorByIndex();
428 | }
429 | }
430 | }
431 |
432 | @Override
433 | public void onAnimationCancel(Animator animation) {
434 |
435 | }
436 |
437 | @Override
438 | public void onAnimationRepeat(Animator animation) {
439 |
440 | }
441 | }
442 | }
443 | }
444 |
--------------------------------------------------------------------------------
/pdmaster/src/main/java/com/martin/pdmaster/PathUtils.java:
--------------------------------------------------------------------------------
1 | package com.martin.pdmaster;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Matrix;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.graphics.PathMeasure;
9 | import android.graphics.Rect;
10 | import android.graphics.RectF;
11 | import android.graphics.Region;
12 | import android.util.Log;
13 |
14 | import com.caverock.androidsvg.PreserveAspectRatio;
15 | import com.caverock.androidsvg.SVG;
16 | import com.caverock.androidsvg.SVGParseException;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | /**
22 | * This class is base on PathView.class in PathView ,
23 | * If you want know more , The link of PathView: https://github.com/geftimov/android-pathview.
24 | *
25 | * Licence of pathview :
26 | *
27 | * Copyright 2016 Georgi Eftimov
28 | * Licensed under the Apache License, Version 2.0 (the "License");
29 | * you may not use this file except in compliance with the License.
30 | * You may obtain a copy of the License at
31 | *
32 | * http://www.apache.org/licenses/LICENSE-2.0
33 | *
34 | * Unless required by applicable law or agreed to in writing, software
35 | * distributed under the License is distributed on an "AS IS" BASIS,
36 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 | * See the License for the specific language governing permissions and
38 | * limitations under the License.
39 | *
40 | *
41 | * 作者:MartinBZDQSM on 2016/8/28 0028.
42 | * 博客:http://www.jianshu.com/users/78f0e5f4a403/latest_articles
43 | * github:https://github.com/MartinBZDQSM
44 | *
45 | * 该类修改自 PathView的SvgUtils 链接:https://github.com/geftimov/android-pathview
46 | */
47 | public class PathUtils {
48 | /**
49 | * It is for logging purposes.
50 | */
51 | private static final String LOG_TAG = "PathLayer";
52 | /**
53 | * 一张svg可能会有多条path路径
54 | */
55 | private final List mPaths = new ArrayList<>();
56 |
57 | public final List mDrawer = new ArrayList<>();
58 |
59 | /**
60 | * The init svg.
61 | */
62 | private SVG mSvg;
63 |
64 | /**
65 | * Init the SVGUtils with a paint1 for coloring.
66 | */
67 | public PathUtils() {
68 | }
69 |
70 | /**
71 | * Loading the svg from the resources.
72 | *
73 | * @param context Context object to get the resources.
74 | * @param svgResource int resource id of the svg.
75 | */
76 | public void load(Context context, int svgResource) {
77 | if (mSvg != null)
78 | return;
79 | try {
80 | mSvg = SVG.getFromResource(context, svgResource);
81 | mSvg.setDocumentPreserveAspectRatio(PreserveAspectRatio.UNSCALED);
82 | } catch (SVGParseException e) {
83 | Log.e(LOG_TAG, "Could not load specified SVG resource", e);
84 | }
85 | }
86 |
87 | /**
88 | * 渲染svg到canvas上,把path回调回来
89 | *
90 | * @param width - the width to scale down the view to,
91 | * @param height - the height to scale down the view to,
92 | * @return All the paths from the svg.
93 | */
94 | public List getPathsForViewport(final int width, final int height) {
95 | Canvas canvas = new Canvas() {
96 | private final Matrix mMatrix = new Matrix();
97 |
98 | @Override
99 | public int getWidth() {
100 | return width;
101 | }
102 |
103 | @Override
104 | public int getHeight() {
105 | return height;
106 | }
107 |
108 | @Override
109 | public void drawPath(Path path, Paint paint) {
110 | Path dst = new Path();
111 | getMatrix(mMatrix);
112 | path.transform(mMatrix, dst);
113 | mPaths.add(new SvgPath(dst));
114 |
115 | Path dst2 = new Path();
116 | getMatrix(mMatrix);
117 | path.transform(mMatrix, dst2);
118 | mDrawer.add(dst2);
119 | }
120 | };
121 |
122 | rescaleCanvas(width, height, canvas);
123 |
124 | return mPaths;
125 | }
126 |
127 | /**
128 | * Draw the svg to the canvas.
129 | *
130 | * @param canvas The canvas to be drawn.
131 | * @param width The width of the canvas.
132 | * @param height The height of the canvas.
133 | */
134 | public void drawSvgAfter(final Canvas canvas, final int width, final int height) {
135 | rescaleCanvas(width, height, canvas);
136 | }
137 |
138 | /**
139 | * 按实际比例进行缩放
140 | *
141 | * @param width The width of the canvas.
142 | * @param height The height of the canvas.
143 | * @param canvas The canvas to be drawn.
144 | */
145 | private void rescaleCanvas(int width, int height, Canvas canvas) {
146 | if (mSvg == null)
147 | return;
148 | final RectF viewBox = mSvg.getDocumentViewBox();
149 |
150 | final float scale = Math.min(width
151 | / (viewBox.width()),
152 | height / (viewBox.height()));
153 |
154 | canvas.translate((width - viewBox.width() * scale) / 2.0f,
155 | (height - viewBox.height() * scale) / 2.0f);
156 | canvas.scale(scale, scale);
157 |
158 | mSvg.renderToCanvas(canvas);
159 | }
160 |
161 |
162 | /**
163 | * Path with bounds for scalling , length and mypaint.
164 | */
165 | public static class SvgPath {
166 |
167 | /**
168 | * Region of the path.
169 | */
170 | private static final Region REGION = new Region();
171 | /**
172 | * This is done for clipping the bounds of the path.
173 | */
174 | private static final Region MAX_CLIP =
175 | new Region(Integer.MIN_VALUE, Integer.MIN_VALUE,
176 | Integer.MAX_VALUE, Integer.MAX_VALUE);
177 | /**
178 | * The path itself.
179 | */
180 | final Path path;
181 |
182 | /**
183 | * The length of the path.
184 | */
185 | float length;
186 | /**
187 | * Listener to notify that an animation step has happened.
188 | */
189 | AnimationStepListener animationStepListener;
190 | /**
191 | * The bounds of the path.
192 | */
193 | final Rect bounds;
194 | /**
195 | * The measure of the path, we can use it later to get segment of it.
196 | */
197 | final PathMeasure measure;
198 |
199 | boolean isMeasure = false;
200 |
201 | float[] point = new float[2];
202 |
203 | /**
204 | * Constructor to add the path and the mypaint.
205 | *
206 | * @param path The path that comes from the rendered svg.
207 | */
208 | SvgPath(Path path) {
209 | this.path = path;
210 | measure = new PathMeasure(path, false);
211 | this.length = measure.getLength();
212 | REGION.setPath(path, MAX_CLIP);
213 | bounds = REGION.getBounds();
214 | }
215 |
216 | /**
217 | * Sets the animation step listener.
218 | *
219 | * @param animationStepListener AnimationStepListener.
220 | */
221 | public void setAnimationStepListener(AnimationStepListener animationStepListener) {
222 | this.animationStepListener = animationStepListener;
223 | }
224 |
225 | /**
226 | * Sets the length of the path.
227 | *
228 | * @param length The length to be set.
229 | */
230 | public void setLength(float length) {
231 | path.reset();
232 | measure.getSegment(0.0f, length, path, true);
233 | measure.getPosTan(length, point, null);
234 | path.rLineTo(0.0f, 0.0f);
235 | if (animationStepListener != null) {
236 | animationStepListener.onAnimationStep();
237 | }
238 | }
239 |
240 | /**
241 | * @return The length of the path.
242 | */
243 | public float getLength() {
244 | return length;
245 | }
246 | }
247 |
248 | public interface AnimationStepListener {
249 |
250 | /**
251 | * Called when an animation step happens.
252 | */
253 | void onAnimationStep();
254 | }
255 |
256 | public List getPaths() {
257 | return mPaths;
258 | }
259 | }
260 |
--------------------------------------------------------------------------------
/pdmaster/src/main/res/drawable/mypaint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/pdmaster/src/main/res/drawable/mypaint.png
--------------------------------------------------------------------------------
/pdmaster/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PDMaster
3 |
4 |
--------------------------------------------------------------------------------
/pdmaster/src/main/res/values/sttr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pdmaster/src/test/java/com/martin/pdmaster/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.martin.pdmaster;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/resources/afterfill.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/resources/afterfill.gif
--------------------------------------------------------------------------------
/resources/ironman.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/resources/ironman.gif
--------------------------------------------------------------------------------
/resources/nancy.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/resources/nancy.gif
--------------------------------------------------------------------------------
/resources/woman.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinHY/PathDraw/bbc3e3d1ab05982aa6d3c8d9532fe624543c4563/resources/woman.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':pdmaster'
2 |
--------------------------------------------------------------------------------