Use formatter for all Haxe code

This commit is contained in:
Joshua Granick
2019-02-14 08:41:20 -08:00
parent b4afa14a13
commit 0c163a80e7
638 changed files with 54759 additions and 59510 deletions

View File

@@ -1,6 +1,5 @@
package;
import format.SVG;
import hxp.*;
import lime.tools.Architecture;
@@ -13,96 +12,82 @@ import sys.io.File;
import sys.io.Process;
import sys.FileSystem;
class SVGExport {
class SVGExport
{
#if (neko && (haxe_210 || haxe3))
public static function __init__ () {
var haxePath = Sys.getEnv ("HAXEPATH");
public static function __init__()
{
var haxePath = Sys.getEnv("HAXEPATH");
var command = (haxePath != null && haxePath != "") ? haxePath + "/haxelib" : "haxelib";
var path = "";
if (FileSystem.exists ("svg.n")) {
path = Path.combine (Sys.getCwd (), "../ndll/");
if (FileSystem.exists("svg.n"))
{
path = Path.combine(Sys.getCwd(), "../ndll/");
}
if (path == "") {
if (path == "")
{
var process = new Process("haxelib", ["path", "lime"]);
var process = new Process ("haxelib", [ "path", "lime" ]);
try
{
while (true)
{
var line = StringTools.trim(process.stdout.readLine());
try {
while (true) {
var line = StringTools.trim (process.stdout.readLine ());
if (StringTools.startsWith (line, "-L ")) {
path = StringTools.trim (line.substr (2));
if (StringTools.startsWith(line, "-L "))
{
path = StringTools.trim(line.substr(2));
break;
}
}
}
catch (e:Dynamic) {}
} catch (e:Dynamic) {}
process.close ();
process.close();
}
switch (System.hostPlatform) {
switch (System.hostPlatform)
{
case WINDOWS:
untyped $loader.path = $array (path + "Windows/", $loader.path);
untyped $loader.path = $array(path + "Windows/", $loader.path);
case MAC:
untyped $loader.path = $array (path + "Mac/", $loader.path);
untyped $loader.path = $array (path + "Mac64/", $loader.path);
untyped $loader.path = $array(path + "Mac/", $loader.path);
untyped $loader.path = $array(path + "Mac64/", $loader.path);
case LINUX:
var arguments = Sys.args ();
var arguments = Sys.args();
var raspberryPi = false;
for (argument in arguments) {
for (argument in arguments)
{
if (argument == "-rpi") raspberryPi = true;
}
if (raspberryPi) {
untyped $loader.path = $array (path + "RPi/", $loader.path);
} else if (System.hostArchitecture == X64) {
untyped $loader.path = $array (path + "Linux64/", $loader.path);
} else {
untyped $loader.path = $array (path + "Linux/", $loader.path);
if (raspberryPi)
{
untyped $loader.path = $array(path + "RPi/", $loader.path);
}
else if (System.hostArchitecture == X64)
{
untyped $loader.path = $array(path + "Linux64/", $loader.path);
}
else
{
untyped $loader.path = $array(path + "Linux/", $loader.path);
}
default:
}
}
#end
public static function main () {
var arguments = Sys.args ();
public static function main()
{
var arguments = Sys.args();
/*if (arguments.length > 0) {
@@ -135,51 +120,44 @@ class SVGExport {
}*/
var words = new Array<String> ();
for (arg in arguments) {
if (arg == "-verbose") {
var words = new Array<String>();
for (arg in arguments)
{
if (arg == "-verbose")
{
Log.verbose = true;
} else {
words.push (arg);
}
else
{
words.push(arg);
}
}
if (words.length > 4 && words[0] == "process") {
try {
if (words.length > 4 && words[0] == "process")
{
try
{
var inputPath = words[1];
var width = Std.parseInt (words[2]);
var height = Std.parseInt (words[3]);
var width = Std.parseInt(words[2]);
var height = Std.parseInt(words[3]);
var outputPath = words[4];
var svg = new SVG (File.getContent (inputPath));
var svg = new SVG(File.getContent(inputPath));
var backgroundColor = 0x00FFFFFF;
var shape = new Shape ();
svg.render (shape.graphics, 0, 0, width, height);
var shape = new Shape();
svg.render(shape.graphics, 0, 0, width, height);
var bitmapData = new BitmapData (width, height, true, backgroundColor);
bitmapData.draw (shape);
File.saveBytes (outputPath, bitmapData.encode (bitmapData.rect, new PNGEncoderOptions ()));
} catch (e:Dynamic) {
Log.error (e);
var bitmapData = new BitmapData(width, height, true, backgroundColor);
bitmapData.draw(shape);
File.saveBytes(outputPath, bitmapData.encode(bitmapData.rect, new PNGEncoderOptions()));
}
catch (e:Dynamic)
{
Log.error(e);
}
}
}
}
}