-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
125 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rootProject.name = 'Lowpoly' | ||
|
41 changes: 41 additions & 0 deletions
41
Lowpoly/src/main/java/com/zzhoujay/lowpoly/Configuration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.