Plugin cleanup
This commit is contained in:
@@ -10,18 +10,18 @@ plugin.drawUI = function(ui) {
|
||||
arm.UIFiles.show("arm", false, function(path) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let parsed = iron.ArmPack.decode(b.bytes);
|
||||
let out = arm.Bytes.ofString(arm.Json.stringify(parsed, function(key, value) {
|
||||
if (arm.StdIs(value, Float32Array)) {
|
||||
let out = core.Bytes.ofString(core.Json.stringify(parsed, function(key, value) {
|
||||
if (core.StdIs(value, Float32Array)) {
|
||||
let ar = Array.from(value);
|
||||
ar.unshift(0); // Annotate array type
|
||||
return ar;
|
||||
}
|
||||
else if (arm.StdIs(value, Uint32Array)) {
|
||||
else if (core.StdIs(value, Uint32Array)) {
|
||||
let ar = Array.from(value);
|
||||
ar.unshift(1);
|
||||
return ar;
|
||||
}
|
||||
else if (arm.StdIs(value, Int16Array)) {
|
||||
else if (core.StdIs(value, Int16Array)) {
|
||||
let ar = Array.from(value);
|
||||
ar.unshift(2);
|
||||
return ar;
|
||||
@@ -35,19 +35,19 @@ plugin.drawUI = function(ui) {
|
||||
if (ui.button(".json to .arm")) {
|
||||
arm.UIFiles.show("json", false, function(path) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let parsed = arm.Json.parse(b.toString());
|
||||
let parsed = core.Json.parse(b.toString());
|
||||
function iterate(d) {
|
||||
for (const n of arm.ReflectFields(d)) {
|
||||
let v = arm.ReflectField(d, n);
|
||||
if (arm.StdIs(v, Array)) {
|
||||
if (arm.StdIs(v[0], Number)) {
|
||||
for (const n of core.ReflectFields(d)) {
|
||||
let v = core.ReflectField(d, n);
|
||||
if (core.StdIs(v, Array)) {
|
||||
if (core.StdIs(v[0], Number)) {
|
||||
arm.Log.trace(n);
|
||||
let ar = null;
|
||||
if (v[0] === 0) ar = new Float32Array(v.length - 1);
|
||||
else if (v[0] === 1) ar = new Uint32Array(v.length - 1);
|
||||
else if (v[0] === 2) ar = new Int16Array(v.length - 1);
|
||||
for (let i = 0; i < v.length - 1; ++i) ar[i] = v[i + 1];
|
||||
arm.ReflectSetField(d, n, ar);
|
||||
core.ReflectSetField(d, n, ar);
|
||||
}
|
||||
else for (const e of v) if (typeof e === 'object') iterate(e);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ plugin.drawUI = function(ui) {
|
||||
|
||||
let updateGraph = function() {
|
||||
if (graph === null) {
|
||||
graphA = arm.Image.createRenderTarget(280, 33);
|
||||
graphB = arm.Image.createRenderTarget(280, 33);
|
||||
graphA = core.Image.createRenderTarget(280, 33);
|
||||
graphB = core.Image.createRenderTarget(280, 33);
|
||||
graph = graphA;
|
||||
}
|
||||
else graph = graph === graphA ? graphB : graphA;
|
||||
@@ -48,7 +48,7 @@ let updateGraph = function() {
|
||||
|
||||
let avg = Math.round(frameTimeAvg * 1000);
|
||||
let miss = avg > 16.7 ? (avg - 16.7) / 16.7 : 0.0;
|
||||
g2.set_color(arm.colorFromFloats(miss, 1 - miss, 0, 1.0));
|
||||
g2.set_color(core.colorFromFloats(miss, 1 - miss, 0, 1.0));
|
||||
g2.fillRect(280 - 3, 33 - avg, 3, avg);
|
||||
|
||||
g2.set_color(0xff000000);
|
||||
@@ -69,6 +69,6 @@ let tick = function(g2) {
|
||||
updateGraph();
|
||||
g2.begin(false);
|
||||
}
|
||||
frameTime = arm.Scheduler.realTime() - lastTime;
|
||||
lastTime = arm.Scheduler.realTime();
|
||||
frameTime = core.Scheduler.realTime() - lastTime;
|
||||
lastTime = core.Scheduler.realTime();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ arm.NodesBrush.list.push(nodes);
|
||||
|
||||
// Brush node
|
||||
arm.Brush.customNodes.set(nodeType, function(node, from) {
|
||||
return Math.sin(arm.Scheduler.time() * node.inputs[0].get(0));
|
||||
return Math.sin(core.Scheduler.time() * node.inputs[0].get(0));
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
let import_stl = function(path, done) {
|
||||
iron.Data.getBlob(path, function(b) {
|
||||
let input = new arm.BytesInput(b.bytes);
|
||||
let input = new core.BytesInput(b.bytes);
|
||||
let header = input.read(80);
|
||||
if (header.getString(0, 5) == "solid") {
|
||||
return; // ascii not supported
|
||||
|
||||
@@ -34,7 +34,7 @@ let import_svg = function(path, done) {
|
||||
let w = a._get_pixels_w();
|
||||
let h = a._get_pixels_h();
|
||||
let pixels = r.buffer.slice(a._get_pixels(), a._get_pixels() + w * h * 4);
|
||||
let image = arm.Image.fromBytes(arm.Bytes.ofData(pixels), w, h);
|
||||
let image = core.Image.fromBytes(core.Bytes.ofData(pixels), w, h);
|
||||
done(image);
|
||||
|
||||
a._destroy();
|
||||
|
||||
@@ -9,7 +9,7 @@ let import_tiff = function(path, done) {
|
||||
let ifds = UTIF.decode(b.bytes.b.bufferValue);
|
||||
UTIF.decodeImage(b.bytes.b.bufferValue, ifds[0]);
|
||||
let rgba = UTIF.toRGBA8(ifds[0]);
|
||||
let image = arm.Image.fromBytes(arm.Bytes.ofData(rgba.buffer), ifds[0].width, ifds[0].height);
|
||||
let image = core.Image.fromBytes(core.Bytes.ofData(rgba.buffer), ifds[0].width, ifds[0].height);
|
||||
done(image);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ function texsynthInpaint(tiling) {
|
||||
|
||||
let bytes_img = l.texpaint.getPixels().b.bufferValue;
|
||||
let bytes_mask = l.texpaint_mask != null ? l.texpaint_mask.getPixels().b.bufferValue : new ArrayBuffer(w * h);
|
||||
let bytes_out = new arm.Bytes(new ArrayBuffer(w * h * 4));
|
||||
let bytes_out = new core.Bytes(new ArrayBuffer(w * h * 4));
|
||||
Krom.texsynthInpaint(w, h, bytes_out.b.bufferValue, bytes_img, bytes_mask, tiling);
|
||||
let image = arm.Image.fromBytes(bytes_out, w, h);
|
||||
let image = core.Image.fromBytes(bytes_out, w, h);
|
||||
|
||||
function _next() {
|
||||
arm.Context.layerIsMask = false;
|
||||
@@ -36,7 +36,7 @@ function texsynthInpaint(tiling) {
|
||||
l.deleteMask();
|
||||
l.texpaint.unload();
|
||||
|
||||
l.texpaint = arm.Image.createRenderTarget(w, h);
|
||||
l.texpaint = core.Image.createRenderTarget(w, h);
|
||||
let g2 = l.texpaint.get_g2();
|
||||
g2.begin(false);
|
||||
g2.drawImage(image, 0, 0);
|
||||
|
||||
+21
-13
@@ -42,6 +42,24 @@ class Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
@:expose("core")
|
||||
class CoreBridge {
|
||||
public static var Json = haxe.Json;
|
||||
public static var ReflectFields = Reflect.fields;
|
||||
public static var ReflectField = Reflect.field;
|
||||
public static var ReflectSetField = Reflect.setField;
|
||||
public static var StdIs = Std.is;
|
||||
public static var Bytes = haxe.io.Bytes;
|
||||
public static var BytesInput = haxe.io.BytesInput;
|
||||
public static var BytesOutput = haxe.io.BytesOutput;
|
||||
public static var Blob = kha.Blob;
|
||||
public static var Image = kha.Image;
|
||||
public static var Scheduler = kha.Scheduler;
|
||||
public static function colorFromFloats(r: Float, g: Float, b: Float, a: Float): kha.Color {
|
||||
return kha.Color.fromFloats(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
@:expose("iron")
|
||||
class IronBridge {
|
||||
public static var App = iron.App;
|
||||
@@ -56,16 +74,6 @@ class IronBridge {
|
||||
|
||||
@:expose("arm")
|
||||
class ArmBridge {
|
||||
public static var Json = haxe.Json;
|
||||
public static var ReflectFields = Reflect.fields;
|
||||
public static var ReflectField = Reflect.field;
|
||||
public static var ReflectSetField = Reflect.setField;
|
||||
public static var StdIs = Std.is;
|
||||
public static var Bytes = haxe.io.Bytes;
|
||||
public static var BytesInput = haxe.io.BytesInput;
|
||||
public static var Blob = kha.Blob;
|
||||
public static var Image = kha.Image;
|
||||
public static var Scheduler = kha.Scheduler;
|
||||
public static var App = arm.App;
|
||||
public static var Config = arm.Config;
|
||||
public static var Context = arm.Context;
|
||||
@@ -92,14 +100,14 @@ class ArmBridge {
|
||||
public static var RenderUtil = arm.util.RenderUtil;
|
||||
public static var UVUtil = arm.util.UVUtil;
|
||||
public static var ViewportUtil = arm.util.ViewportUtil;
|
||||
public static function colorFromFloats(r: Float, g: Float, b: Float, a: Float): kha.Color {
|
||||
return kha.Color.fromFloats(r, g, b, a);
|
||||
}
|
||||
public static var PngWriter = arm.format.PngWriter;
|
||||
public static var PngTools = arm.format.PngTools;
|
||||
}
|
||||
|
||||
@:expose("zui")
|
||||
class ZuiBridge {
|
||||
public static var Handle = zui.Zui.Handle;
|
||||
public static var Zui = zui.Zui;
|
||||
public static var Ext = zui.Ext;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user