diff --git a/.idea/.name b/.idea/.name
index 686f38b..0fa37a3 100644
--- a/.idea/.name
+++ b/.idea/.name
@@ -1 +1 @@
-LowPoly
\ No newline at end of file
+Lowpoly
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 96cc43e..e559d2b 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -18,5 +18,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index bc42521..02642ab 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -13,23 +13,7 @@
-
+
-
-
-
-
- 1.8
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 7831102..0eab2a4 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,9 @@
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/Lowpoly/build.gradle
similarity index 100%
rename from build.gradle
rename to Lowpoly/build.gradle
diff --git a/Lowpoly/settings.gradle b/Lowpoly/settings.gradle
new file mode 100644
index 0000000..f5f3e40
--- /dev/null
+++ b/Lowpoly/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'Lowpoly'
+
diff --git a/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Configuration.java b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Configuration.java
new file mode 100644
index 0000000..defe6e9
--- /dev/null
+++ b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Configuration.java
@@ -0,0 +1,41 @@
+package com.zzhoujay.lowpoly;
+
+/**
+ * Created by zhou on 2017/5/14.
+ */
+public class Configuration {
+
+ public static final int DEFAULT_ACCURACY = 50;
+ public static final float DEFAULT_SCALE = 1;
+ public static final boolean DEFAULT_FILL = true;
+ public static final String DEFAULT_FORMAT = "png";
+ public static final boolean DEFAULT_ANTI_ALIASING = false;
+ public static final int DEFAULT_POINT_COUNT = 300;
+
+ public static final String ACCURACY = "accuracy";
+ public static final String SCALE = "scale";
+ public static final String FILL = "fill";
+ public static final String FORMAT = "format";
+ public static final String ANTI_ALIASING = "antiAliasing";
+ public static final String POINT_COUNT = "pointCount";
+
+ public final int accuracy;
+ public final float scale;
+ public final boolean fill;
+ public final String format;
+ public final boolean antiAliasing;
+ public final int pointCount;
+
+ public Configuration() {
+ this(DEFAULT_ACCURACY, DEFAULT_SCALE, DEFAULT_FILL, DEFAULT_FORMAT, DEFAULT_ANTI_ALIASING, DEFAULT_POINT_COUNT);
+ }
+
+ public Configuration(int accuracy, float scale, boolean fill, String format, boolean antiAliasing, int pointCount) {
+ this.accuracy = accuracy;
+ this.scale = scale;
+ this.fill = fill;
+ this.format = format;
+ this.antiAliasing = antiAliasing;
+ this.pointCount = pointCount;
+ }
+}
diff --git a/src/main/java/com/zzhoujay/lowpoly/Delaunay.java b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Delaunay.java
similarity index 100%
rename from src/main/java/com/zzhoujay/lowpoly/Delaunay.java
rename to Lowpoly/src/main/java/com/zzhoujay/lowpoly/Delaunay.java
diff --git a/src/main/java/com/zzhoujay/lowpoly/LowPoly.java b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/LowPoly.java
similarity index 93%
rename from src/main/java/com/zzhoujay/lowpoly/LowPoly.java
rename to Lowpoly/src/main/java/com/zzhoujay/lowpoly/LowPoly.java
index 90fdc9e..7502980 100644
--- a/src/main/java/com/zzhoujay/lowpoly/LowPoly.java
+++ b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/LowPoly.java
@@ -16,8 +16,8 @@
*/
public final class LowPoly {
- public static void generate(InputStream inputStream, OutputStream outputStream) throws IOException {
- generate(inputStream, outputStream, 50, 1, true, "png", false, 300);
+ public static void generate(InputStream inputStream, OutputStream outputStream, Configuration configuration) throws IOException {
+ generate(inputStream, outputStream, configuration.accuracy, configuration.scale, configuration.fill, configuration.format, configuration.antiAliasing, configuration.pointCount);
}
/**
diff --git a/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Simple.java b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Simple.java
new file mode 100644
index 0000000..4d0e8ae
--- /dev/null
+++ b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Simple.java
@@ -0,0 +1,69 @@
+package com.zzhoujay.lowpoly;
+
+import java.io.*;
+import java.util.Properties;
+
+/**
+ * Created by zhou on 16-5-12.
+ */
+public class Simple {
+
+ public static void main(String[] args) throws IOException {
+ if (args.length <= 0) {
+ return;
+ }
+ if (args.length == 1) {
+ FileOutputStream fileOutputStream = new FileOutputStream(args[0]);
+ createConfiguration(fileOutputStream);
+ System.out.println("默认配置文件已创建");
+ return;
+ }
+ String in = args[0];
+ String out = args[1];
+ File inFile = new File(in);
+ if (inFile.exists()) {
+ File outFile = new File(out);
+ FileInputStream inputStream = new FileInputStream(inFile);
+ FileOutputStream outputStream = new FileOutputStream(outFile);
+ long lastTime = System.currentTimeMillis();
+ Configuration configuration;
+ if (args.length >= 3) {
+ FileInputStream fileInputStream = new FileInputStream(args[2]);
+ configuration = loadConfiguration(fileInputStream);
+ } else {
+ configuration = new Configuration();
+ }
+
+ LowPoly.generate(inputStream, outputStream, configuration);
+ System.out.println("目标已保存至:" + outFile.getAbsolutePath());
+ System.out.println("用时:" + (System.currentTimeMillis() - lastTime));
+ } else {
+ System.out.println("源文件不存在");
+ }
+ }
+
+ private static void createConfiguration(OutputStream outputStream) throws IOException {
+ Properties properties = new Properties();
+ properties.setProperty(Configuration.ACCURACY, String.valueOf(Configuration.DEFAULT_ACCURACY));
+ properties.setProperty(Configuration.SCALE, String.valueOf(Configuration.DEFAULT_SCALE));
+ properties.setProperty(Configuration.FILL, String.valueOf(Configuration.DEFAULT_FILL));
+ properties.setProperty(Configuration.FORMAT, Configuration.DEFAULT_FORMAT);
+ properties.setProperty(Configuration.ANTI_ALIASING, String.valueOf(Configuration.DEFAULT_ANTI_ALIASING));
+ properties.setProperty(Configuration.POINT_COUNT, String.valueOf(Configuration.DEFAULT_POINT_COUNT));
+ properties.store(outputStream, "default");
+ }
+
+ private static Configuration loadConfiguration(InputStream inputStream) throws IOException {
+ Properties properties = new Properties();
+ properties.load(inputStream);
+
+ String accuracy = properties.getProperty(Configuration.ACCURACY, String.valueOf(Configuration.DEFAULT_ACCURACY));
+ String scale = properties.getProperty(Configuration.SCALE, String.valueOf(Configuration.DEFAULT_SCALE));
+ String fill = properties.getProperty(Configuration.FILL, String.valueOf(Configuration.DEFAULT_FILL));
+ String format = properties.getProperty(Configuration.FORMAT, Configuration.DEFAULT_FORMAT);
+ String antiAliasing = properties.getProperty(Configuration.ANTI_ALIASING, String.valueOf(Configuration.DEFAULT_ANTI_ALIASING));
+ String pointCount = properties.getProperty(Configuration.POINT_COUNT, String.valueOf(Configuration.DEFAULT_POINT_COUNT));
+
+ return new Configuration(Integer.valueOf(accuracy), Float.valueOf(scale), Boolean.valueOf(fill), format, Boolean.valueOf(antiAliasing), Integer.valueOf(pointCount));
+ }
+}
diff --git a/src/main/java/com/zzhoujay/lowpoly/Sobel.java b/Lowpoly/src/main/java/com/zzhoujay/lowpoly/Sobel.java
similarity index 100%
rename from src/main/java/com/zzhoujay/lowpoly/Sobel.java
rename to Lowpoly/src/main/java/com/zzhoujay/lowpoly/Sobel.java
diff --git a/src/main/java/com/zzhoujay/lowpoly/Simple.java b/src/main/java/com/zzhoujay/lowpoly/Simple.java
deleted file mode 100644
index e65077d..0000000
--- a/src/main/java/com/zzhoujay/lowpoly/Simple.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.zzhoujay.lowpoly;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-/**
- * Created by zhou on 16-5-12.
- */
-public class Simple {
-
- public static void main(String[] args) throws IOException {
- if (args.length < 2) {
- throw new RuntimeException("请输入有效的图片");
- }
- String in = args[0];
- String out = args[1];
- File inFile = new File(in);
- if (inFile.exists()) {
- File outFile = new File(out);
- FileInputStream inputStream = new FileInputStream(inFile);
- FileOutputStream outputStream = new FileOutputStream(outFile);
- long lastTime = System.currentTimeMillis();
- if (args.length >= 8) {
- int accuracy = Integer.valueOf(args[2]);
- float scale = Float.valueOf(args[3]);
- boolean fill = Boolean.valueOf(args[4]);
- String format = args[5];
- boolean antiAliasing = Boolean.valueOf(args[6]);
- int pointCount = Integer.valueOf(args[7]);
- LowPoly.generate(inputStream, outputStream, accuracy, scale, !fill, format, antiAliasing, pointCount);
- } else {
- LowPoly.generate(inputStream, outputStream);
- }
- System.out.println("目标已保存至:" + outFile.getAbsolutePath());
- System.out.println("用时:" + (System.currentTimeMillis() - lastTime));
- } else {
- throw new RuntimeException("源文件不存在");
- }
- }
-}