diff --git a/cart/as/build.js b/cart/as/build.js
index 68c8411..c336600 100644
--- a/cart/as/build.js
+++ b/cart/as/build.js
@@ -18,6 +18,7 @@ await writeFile('build/tmp.ts', (await readFile('null0.ts')) + '\n// user-code:\
const { error, stdout, stderr, stats } = await asc.main([
'build/tmp.ts',
+ '--debug',
'--runtime', 'minimal',
'--config', './node_modules/@assemblyscript/wasi-shim/asconfig.json',
'--optimizeLevel', '3',
diff --git a/docs/cart/colorbars.null0 b/docs/cart/colorbars.null0
index 1417c39..dcc4229 100644
Binary files a/docs/cart/colorbars.null0 and b/docs/cart/colorbars.null0 differ
diff --git a/docs/cart/draw.null0 b/docs/cart/draw.null0
index b2c9d87..1ffc6f5 100644
Binary files a/docs/cart/draw.null0 and b/docs/cart/draw.null0 differ
diff --git a/docs/cart/example-as.null0 b/docs/cart/example-as.null0
index 42f469c..72f5068 100644
Binary files a/docs/cart/example-as.null0 and b/docs/cart/example-as.null0 differ
diff --git a/docs/cart/filesystem.null0 b/docs/cart/filesystem.null0
index d20d612..77586fa 100644
Binary files a/docs/cart/filesystem.null0 and b/docs/cart/filesystem.null0 differ
diff --git a/docs/cart/flappybird.null0 b/docs/cart/flappybird.null0
index 235545b..3f11a52 100644
Binary files a/docs/cart/flappybird.null0 and b/docs/cart/flappybird.null0 differ
diff --git a/docs/cart/hello.null0 b/docs/cart/hello.null0
index 7df8357..4303d04 100644
Binary files a/docs/cart/hello.null0 and b/docs/cart/hello.null0 differ
diff --git a/docs/cart/input.null0 b/docs/cart/input.null0
index de467c4..52c28f8 100644
Binary files a/docs/cart/input.null0 and b/docs/cart/input.null0 differ
diff --git a/docs/cart/justlog.null0 b/docs/cart/justlog.null0
index 226de2e..db4f0b7 100644
Binary files a/docs/cart/justlog.null0 and b/docs/cart/justlog.null0 differ
diff --git a/docs/cart/sound.null0 b/docs/cart/sound.null0
index d784620..41f8477 100644
Binary files a/docs/cart/sound.null0 and b/docs/cart/sound.null0 differ
diff --git a/docs/cart/tracker.null0 b/docs/cart/tracker.null0
index 207f821..5b63e7c 100644
Binary files a/docs/cart/tracker.null0 and b/docs/cart/tracker.null0 differ
diff --git a/docs/cart/typesizes.null0 b/docs/cart/typesizes.null0
index ab1e3d2..b81066a 100644
Binary files a/docs/cart/typesizes.null0 and b/docs/cart/typesizes.null0 differ
diff --git a/docs/index.html b/docs/index.html
index 6811c63..b03bed9 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -28,12 +28,12 @@
Here are some example carts:
-
-
-
+
+
+
-
+
diff --git a/docs/null0.js b/docs/null0.js
index d6f3aa7..87712db 100755
--- a/docs/null0.js
+++ b/docs/null0.js
@@ -1,5 +1,5 @@
-import loadCart from "./wasm/null0.mjs";
-import wireCartToHost from "./null0_wasm.js";
+import loadCart from './wasm/null0.mjs'
+import wireCartToHost from './null0_wasm.js'
export const Buttons = {
A: 7,
@@ -13,57 +13,57 @@ export const Buttons = {
UP: 1,
DOWN: 3,
LEFT: 4,
- RIGHT: 2,
-};
+ RIGHT: 2
+}
// get just the null0 wasm-host (emscripten)
-export async function getHost(
+export async function getHost (
cartUrl,
- canvas = document.body.appendChild(document.createElement("canvas")),
+ canvas = document.body.appendChild(document.createElement('canvas'))
) {
- const cartname = cartUrl.split("/").pop().split(".")[0];
+ const cartname = cartUrl.split('/').pop().split('.')[0]
const host = await loadCart({
canvas,
preRun: async function ({ FS }) {
- await FS.createPreloadedFile("/", cartname, cartUrl, true, false);
+ await FS.createPreloadedFile('/', cartname, cartUrl, true, false)
},
// for some reason it strips off .null0
- arguments: [`/${cartname}`],
- });
+ arguments: [`/${cartname}`]
+ })
// read a file from inside the cart
host.readCartFile = (filename) => {
- const filenamePtr = host._malloc(filename.length + 1);
- host.stringToUTF8(filename, filenamePtr, filename.length + 1);
- const bytesHostPtr = host._malloc(4);
- const retPtr = host._null0_file_read(filenamePtr, bytesHostPtr);
+ const filenamePtr = host._malloc(filename.length + 1)
+ host.stringToUTF8(filename, filenamePtr, filename.length + 1)
+ const bytesHostPtr = host._malloc(4)
+ const retPtr = host._null0_file_read(filenamePtr, bytesHostPtr)
const r = host.HEAPU8.slice(
retPtr,
- retPtr + host.HEAPU32[bytesHostPtr / 4],
- );
- host._free(bytesHostPtr);
- host._free(filenamePtr);
- host._free(retPtr);
- return r;
- };
-
- return host;
+ retPtr + host.HEAPU32[bytesHostPtr / 4]
+ )
+ host._free(bytesHostPtr)
+ host._free(filenamePtr)
+ host._free(retPtr)
+ return r
+ }
+
+ return host
}
// setup a cart with engine
-export async function setupCart(
+export async function setupCart (
url,
- canvas = document.body.appendChild(document.createElement("canvas")),
+ canvas = document.body.appendChild(document.createElement('canvas'))
) {
- const host = await getHost(url, canvas);
- const out = { host };
- const cart = {};
+ const host = await getHost(url, canvas)
+ const out = { host }
+ const cart = {}
- canvas.width = 320;
- canvas.height = 240;
- canvas.setAttribute("tabindex", 0);
- canvas.addEventListener("click", () => canvas.focus());
+ canvas.width = 320
+ canvas.height = 240
+ canvas.setAttribute('tabindex', 0)
+ canvas.addEventListener('click', () => canvas.focus())
// TODO: focus/unfocus handlers for sound
@@ -72,171 +72,171 @@ export async function setupCart(
// minimal WASI that only allows console logging
wasi_snapshot_preview1: {
- fd_write(fd, iovsPtr, iovsLength, bytesWrittenPtr) {
+ fd_write (fd, iovsPtr, iovsLength, bytesWrittenPtr) {
const iovs = new Uint32Array(
cart.memory.buffer,
iovsPtr,
- iovsLength * 2,
- );
+ iovsLength * 2
+ )
if (fd === 1 || fd === 2) {
// stdout/stderr
- let text = "";
- let totalBytesWritten = 0;
+ let text = ''
+ let totalBytesWritten = 0
for (let i = 0; i < iovsLength * 2; i += 2) {
- const offset = iovs[i];
- const length = iovs[i + 1];
- text += cart.getString(offset, length);
- totalBytesWritten += length;
+ const offset = iovs[i]
+ const length = iovs[i + 1]
+ text += cart.getString(offset, length)
+ totalBytesWritten += length
}
- cart.view.setInt32(bytesWrittenPtr, totalBytesWritten, true);
+ cart.view.setInt32(bytesWrittenPtr, totalBytesWritten, true)
// not exactly right, since it will add newlines, but this covers printf and stuff
- text = text.replace(/\n*$/, "");
+ text = text.replace(/\n*$/, '')
if (fd === 1) {
- console.log(text);
+ console.log(text)
} else {
- console.error(text);
+ console.error(text)
}
}
- return 0;
+ return 0
},
- fd_close() {
- return 0;
+ fd_close () {
+ return 0
},
- fd_fdstat_get() {
- return 0;
+ fd_fdstat_get () {
+ return 0
},
- fd_seek() {
- return 0;
+ fd_seek () {
+ return 0
},
- proc_exit(status) {
- console.error("exit", status);
- return 0;
- },
- },
- };
+ proc_exit (status) {
+ console.error('exit', status)
+ return 0
+ }
+ }
+ }
- const wasmBytes = host.readCartFile("main.wasm");
- const cartMod = await WebAssembly.compile(wasmBytes);
- const { exports } = await WebAssembly.instantiate(cartMod, imports);
+ const wasmBytes = host.readCartFile('main.wasm')
+ const cartMod = await WebAssembly.compile(wasmBytes)
+ const { exports } = await WebAssembly.instantiate(cartMod, imports)
for (const k of Object.keys(exports)) {
- cart[k] = exports[k];
+ cart[k] = exports[k]
}
- const d = new TextDecoder();
+ const d = new TextDecoder()
cart.getString = (offset, length) =>
- d.decode(exports.memory.buffer.slice(offset, offset + length));
- cart.view = new DataView(exports.memory.buffer);
+ d.decode(exports.memory.buffer.slice(offset, offset + length))
+ cart.view = new DataView(exports.memory.buffer)
- out.cart = cart;
+ out.cart = cart
if (cart._start) {
- cart._start();
+ cart._start()
}
if (cart.load) {
- cart.load();
+ cart.load()
}
if (cart.buttonDown) {
- canvas.addEventListener("keydown", ({ key }) => {
- if (key === "z") {
- cart.buttonDown(Buttons.B);
+ canvas.addEventListener('keydown', ({ key }) => {
+ if (key === 'z') {
+ cart.buttonDown(Buttons.B)
}
- if (key === "x") {
- cart.buttonDown(Buttons.A);
+ if (key === 'x') {
+ cart.buttonDown(Buttons.A)
}
- if (key === "a") {
- cart.buttonDown(Buttons.Y);
+ if (key === 'a') {
+ cart.buttonDown(Buttons.Y)
}
- if (key === "s") {
- cart.buttonDown(Buttons.X);
+ if (key === 's') {
+ cart.buttonDown(Buttons.X)
}
- if (key === "Shift") {
- cart.buttonDown(Buttons.SELECT);
+ if (key === 'Shift') {
+ cart.buttonDown(Buttons.SELECT)
}
- if (key === "Enter") {
- cart.buttonDown(Buttons.START);
+ if (key === 'Enter') {
+ cart.buttonDown(Buttons.START)
}
- if (key === "q") {
- cart.buttonDown(Buttons.L);
+ if (key === 'q') {
+ cart.buttonDown(Buttons.L)
}
- if (key === "w") {
- cart.buttonDown(Buttons.R);
+ if (key === 'w') {
+ cart.buttonDown(Buttons.R)
}
- if (key === "ArrowUp") {
- cart.buttonDown(Buttons.UP);
+ if (key === 'ArrowUp') {
+ cart.buttonDown(Buttons.UP)
}
- if (key === "ArrowDown") {
- cart.buttonDown(Buttons.DOWN);
+ if (key === 'ArrowDown') {
+ cart.buttonDown(Buttons.DOWN)
}
- if (key === "ArrowLeft") {
- cart.buttonDown(Buttons.LEFT);
+ if (key === 'ArrowLeft') {
+ cart.buttonDown(Buttons.LEFT)
}
- if (key === "ArrowRight") {
- cart.buttonDown(Buttons.RIGHT);
+ if (key === 'ArrowRight') {
+ cart.buttonDown(Buttons.RIGHT)
}
- });
+ })
}
if (cart.buttonUp) {
- canvas.addEventListener("keyup", ({ key }) => {
- if (key === "z") {
- cart.buttonUp(Buttons.B);
+ canvas.addEventListener('keyup', ({ key }) => {
+ if (key === 'z') {
+ cart.buttonUp(Buttons.B)
}
- if (key === "x") {
- cart.buttonUp(Buttons.A);
+ if (key === 'x') {
+ cart.buttonUp(Buttons.A)
}
- if (key === "a") {
- cart.buttonUp(Buttons.Y);
+ if (key === 'a') {
+ cart.buttonUp(Buttons.Y)
}
- if (key === "s") {
- cart.buttonUp(Buttons.X);
+ if (key === 's') {
+ cart.buttonUp(Buttons.X)
}
- if (key === "Shift") {
- cart.buttonUp(Buttons.SELECT);
+ if (key === 'Shift') {
+ cart.buttonUp(Buttons.SELECT)
}
- if (key === "Enter") {
- cart.buttonUp(Buttons.START);
+ if (key === 'Enter') {
+ cart.buttonUp(Buttons.START)
}
- if (key === "q") {
- cart.buttonUp(Buttons.L);
+ if (key === 'q') {
+ cart.buttonUp(Buttons.L)
}
- if (key === "w") {
- cart.buttonUp(Buttons.R);
+ if (key === 'w') {
+ cart.buttonUp(Buttons.R)
}
- if (key === "ArrowUp") {
- cart.buttonUp(Buttons.UP);
+ if (key === 'ArrowUp') {
+ cart.buttonUp(Buttons.UP)
}
- if (key === "ArrowDown") {
- cart.buttonUp(Buttons.DOWN);
+ if (key === 'ArrowDown') {
+ cart.buttonUp(Buttons.DOWN)
}
- if (key === "ArrowLeft") {
- cart.buttonUp(Buttons.LEFT);
+ if (key === 'ArrowLeft') {
+ cart.buttonUp(Buttons.LEFT)
}
- if (key === "ArrowRight") {
- cart.buttonUp(Buttons.RIGHT);
+ if (key === 'ArrowRight') {
+ cart.buttonUp(Buttons.RIGHT)
}
- });
+ })
}
const cartUpdate = () => {
if (cart.update) {
- cart.update();
+ cart.update()
}
- window.requestAnimationFrame(cartUpdate);
+ window.requestAnimationFrame(cartUpdate)
if (cart.frameCallback) {
- cart.frameCallback();
+ cart.frameCallback()
}
- };
- window.requestAnimationFrame(cartUpdate);
+ }
+ window.requestAnimationFrame(cartUpdate)
- return out;
+ return out
}
-export default setupCart;
+export default setupCart
diff --git a/docs/null0_wasm.js b/docs/null0_wasm.js
index 18855bd..a31cecf 100755
--- a/docs/null0_wasm.js
+++ b/docs/null0_wasm.js
@@ -1,234 +1,234 @@
// Null0 host interface for web
-const MAX_STRING_LEN = 1024 * 20;
+const MAX_STRING_LEN = 1024 * 20
-const td = new TextDecoder();
+const td = new TextDecoder()
-export default function wireCartToHost(host, cart) {
+export default function wireCartToHost (host, cart) {
const copyBytesFromCart = (cartPtr, size, retPtr) => {
- const cartMem = new DataView(cart.memory.buffer);
- const hostPtr = retPtr || host._malloc(size);
+ const cartMem = new DataView(cart.memory.buffer)
+ const hostPtr = retPtr || host._malloc(size)
for (let b = 0; b < size; b++) {
- host.HEAPU8[hostPtr + b] = cartMem.getUint8(cartPtr + b);
+ host.HEAPU8[hostPtr + b] = cartMem.getUint8(cartPtr + b)
}
- return hostPtr;
- };
+ return hostPtr
+ }
const copyBytesToCart = (hostPtr, size, retPtr) => {
- const cartMem = new DataView(cart.memory.buffer);
- const cartPtr = retPtr || cart.malloc(size);
+ const cartMem = new DataView(cart.memory.buffer)
+ const cartPtr = retPtr || cart.malloc(size)
for (let b = 0; b < size; b++) {
- cartMem.setUint8(cartPtr + b, host.HEAPU8[hostPtr + b]);
+ cartMem.setUint8(cartPtr + b, host.HEAPU8[hostPtr + b])
}
- return cartPtr;
- };
+ return cartPtr
+ }
const cartStrlen = (pointer) => {
- const cartMem = new DataView(cart.memory.buffer);
- let end = pointer;
+ const cartMem = new DataView(cart.memory.buffer)
+ let end = pointer
while (end < pointer + MAX_STRING_LEN) {
if (cartMem.getUint8(end) === 0) {
- break;
+ break
}
- end++;
+ end++
}
- return end - pointer;
- };
+ return end - pointer
+ }
const hostStrlen = (pointer) => {
- let end = pointer;
+ let end = pointer
while (end < pointer + MAX_STRING_LEN) {
if (host.HEAPU8[end] === 0) {
- break;
+ break
}
- end++;
+ end++
}
- return end - pointer;
- };
+ return end - pointer
+ }
- const cartStr = (pointer) => cart.getString(pointer, cartStrlen(pointer));
+ const cartStr = (pointer) => cart.getString(pointer, cartStrlen(pointer))
return {
- trace(str) {
- console.log(cartStr(str));
+ trace (str) {
+ console.log(cartStr(str))
},
- current_time() {
- return BigInt(Date.now());
+ current_time () {
+ return BigInt(Date.now())
},
- delta_time() {
- return host._null0_delta_time();
+ delta_time () {
+ return host._null0_delta_time()
},
- random_int(min, max) {
- return host._null0_random_int();
+ random_int (min, max) {
+ return host._null0_random_int()
},
- load_sound(filename) {
+ load_sound (filename) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const r = host._null0_load_sound(filenameHostPtr);
- host._free(filenameHostPtr);
- return r;
- },
- play_sound(sound, loop) {
- host._null0_play_sound(sound, loop);
- },
- stop_sound(sound) {
- host._null0_stop_sound(sound);
- },
- new_sfx(params) {
- const paramsHostPtr = copyBytesFromCart(params, 96);
- const r = host._null0_new_sfx(paramsHostPtr);
- host._free(paramsHostPtr);
- return r;
- },
- preset_sfx(params, type) {
- const paramsHostPtr = copyBytesFromCart(params, 96);
- host._null0_preset_sfx(paramsHostPtr, type);
- copyBytesToCart(paramsHostPtr, 96, params);
- host._free(paramsHostPtr);
- },
- randomize_sfx(params, waveType) {
- const paramsHostPtr = copyBytesFromCart(params, 96);
- host._null0_randomize_sfx(paramsHostPtr, waveType);
- copyBytesToCart(params, 96, paramsHostPtr);
- host._free(paramsHostPtr);
- },
- mutate_sfx(params, range, mask) {
- const paramsHostPtr = copyBytesFromCart(params, 96);
- host._null0_mutate_sfx(paramsHostPtr, range, mask);
- host._free(paramsHostPtr);
- },
- load_sfx(retPtr, filename) {
+ cartStrlen(filename) + 1
+ )
+ const r = host._null0_load_sound(filenameHostPtr)
+ host._free(filenameHostPtr)
+ return r
+ },
+ play_sound (sound, loop) {
+ host._null0_play_sound(sound, loop)
+ },
+ stop_sound (sound) {
+ host._null0_stop_sound(sound)
+ },
+ new_sfx (params) {
+ const paramsHostPtr = copyBytesFromCart(params, 96)
+ const r = host._null0_new_sfx(paramsHostPtr)
+ host._free(paramsHostPtr)
+ return r
+ },
+ preset_sfx (params, type) {
+ const paramsHostPtr = copyBytesFromCart(params, 96)
+ host._null0_preset_sfx(paramsHostPtr, type)
+ copyBytesToCart(paramsHostPtr, 96, params)
+ host._free(paramsHostPtr)
+ },
+ randomize_sfx (params, waveType) {
+ const paramsHostPtr = copyBytesFromCart(params, 96)
+ host._null0_randomize_sfx(paramsHostPtr, waveType)
+ copyBytesToCart(params, 96, paramsHostPtr)
+ host._free(paramsHostPtr)
+ },
+ mutate_sfx (params, range, mask) {
+ const paramsHostPtr = copyBytesFromCart(params, 96)
+ host._null0_mutate_sfx(paramsHostPtr, range, mask)
+ host._free(paramsHostPtr)
+ },
+ load_sfx (retPtr, filename) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const retHostPtr = host._malloc(96);
- host._null0_load_sfx(retHostPtr, filenameHostPtr);
- copyBytesToCart(retHostPtr, 96, retPtr);
- host._free(retHostPtr);
- host._free(filenameHostPtr);
+ cartStrlen(filename) + 1
+ )
+ const retHostPtr = host._malloc(96)
+ host._null0_load_sfx(retHostPtr, filenameHostPtr)
+ copyBytesToCart(retHostPtr, 96, retPtr)
+ host._free(retHostPtr)
+ host._free(filenameHostPtr)
},
- unload_sound(sound) {
- host._null0_unload_sound(sound);
+ unload_sound (sound) {
+ host._null0_unload_sound(sound)
},
- key_pressed(key) {
- return host._null0_key_pressed(key);
+ key_pressed (key) {
+ return host._null0_key_pressed(key)
},
- key_down(key) {
- return host._null0_key_down(key);
+ key_down (key) {
+ return host._null0_key_down(key)
},
- key_released(key) {
- return host._null0_key_released(key);
+ key_released (key) {
+ return host._null0_key_released(key)
},
- key_up(key) {
- return host._null0_key_up(key);
+ key_up (key) {
+ return host._null0_key_up(key)
},
- gamepad_button_pressed(gamepad, button) {
- return host._null0_gamepad_button_pressed(gamepad, button);
+ gamepad_button_pressed (gamepad, button) {
+ return host._null0_gamepad_button_pressed(gamepad, button)
},
- gamepad_button_down(gamepad, button) {
- return host._null0_gamepad_button_down(gamepad, button);
+ gamepad_button_down (gamepad, button) {
+ return host._null0_gamepad_button_down(gamepad, button)
},
- gamepad_button_released(gamepad, button) {
- return host._null0_gamepad_button_released(gamepad, button);
+ gamepad_button_released (gamepad, button) {
+ return host._null0_gamepad_button_released(gamepad, button)
},
- mouse_position(retPtr) {
- const hostRetPtr = host._malloc(8);
- host._null0_mouse_position(hostRetPtr);
- copyBytesToCart(hostRetPtr, 8, retPtr);
- host._free(hostRetPtr);
+ mouse_position (retPtr) {
+ const hostRetPtr = host._malloc(8)
+ host._null0_mouse_position(hostRetPtr)
+ copyBytesToCart(hostRetPtr, 8, retPtr)
+ host._free(hostRetPtr)
},
- mouse_button_pressed(button) {
- return host._null0_mouse_button_pressed(button);
+ mouse_button_pressed (button) {
+ return host._null0_mouse_button_pressed(button)
},
- mouse_button_down(button) {
- return host._null0_mouse_button_down(button);
+ mouse_button_down (button) {
+ return host._null0_mouse_button_down(button)
},
- mouse_button_released(button) {
- return host._null0_mouse_button_released(button);
+ mouse_button_released (button) {
+ return host._null0_mouse_button_released(button)
},
- mouse_button_up(button) {
- return host._null0_mouse_button_up(button);
+ mouse_button_up (button) {
+ return host._null0_mouse_button_up(button)
},
- new_image(width, height, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const r = host._null0_clear(width, height, hostColorPtr);
- host._free(hostColorPtr);
- return r;
+ new_image (width, height, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const r = host._null0_clear(width, height, hostColorPtr)
+ host._free(hostColorPtr)
+ return r
},
- image_copy(image) {
- return host._null0_image_copy(image);
+ image_copy (image) {
+ return host._null0_image_copy(image)
},
- image_subimage(image, x, y, width, height) {
- return host._null0_image_subimage(image, x, y, width, height);
+ image_subimage (image, x, y, width, height) {
+ return host._null0_image_subimage(image, x, y, width, height)
},
- clear(color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_clear(hostColorPtr);
- host._free(hostColorPtr);
+ clear (color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_clear(hostColorPtr)
+ host._free(hostColorPtr)
},
- draw_point(x, y, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_point(x, y, hostColorPtr);
- host._free(hostColorPtr);
+ draw_point (x, y, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_point(x, y, hostColorPtr)
+ host._free(hostColorPtr)
},
- draw_line(startPosX, startPosY, endPosX, endPosY, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_line (startPosX, startPosY, endPosX, endPosY, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_line(
startPosX,
startPosY,
endPosX,
endPosY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- },
- draw_rectangle(posX, posY, width, height, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_rectangle(posX, posY, width, height, hostColorPtr);
- host._free(hostColorPtr);
- },
- draw_triangle(x1, y1, x2, y2, x3, y3, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_triangle(x1, y1, x2, y2, x3, y3, hostColorPtr);
- host._free(hostColorPtr);
- },
- draw_ellipse(centerX, centerY, radiusX, radiusY, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ },
+ draw_rectangle (posX, posY, width, height, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_rectangle(posX, posY, width, height, hostColorPtr)
+ host._free(hostColorPtr)
+ },
+ draw_triangle (x1, y1, x2, y2, x3, y3, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_triangle(x1, y1, x2, y2, x3, y3, hostColorPtr)
+ host._free(hostColorPtr)
+ },
+ draw_ellipse (centerX, centerY, radiusX, radiusY, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_ellipse(
centerX,
centerY,
radiusX,
radiusY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- },
- draw_circle(centerX, centerY, radius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_circle(centerX, centerY, radius, hostColorPtr);
- host._free(hostColorPtr);
- },
- draw_polygon(points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const size = numPoints * 8;
- const hostPointsPtr = copyBytesFromCart(points, size);
- host._null0_draw_polygon(hostPointsPtr, numPoints, hostColorPtr);
- host._free(hostColorPtr);
- host._free(hostPointsPtr);
- },
- draw_polyline(points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const size = numPoints * 8;
- const hostPointsPtr = copyBytesFromCart(points, size);
- host._null0_draw_polyline(hostPointsPtr, numPoints, hostColorPtr);
- host._free(hostColorPtr);
- host._free(hostPointsPtr);
- },
- draw_arc(centerX, centerY, radius, startAngle, endAngle, segments, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ },
+ draw_circle (centerX, centerY, radius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_circle(centerX, centerY, radius, hostColorPtr)
+ host._free(hostColorPtr)
+ },
+ draw_polygon (points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const size = numPoints * 8
+ const hostPointsPtr = copyBytesFromCart(points, size)
+ host._null0_draw_polygon(hostPointsPtr, numPoints, hostColorPtr)
+ host._free(hostColorPtr)
+ host._free(hostPointsPtr)
+ },
+ draw_polyline (points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const size = numPoints * 8
+ const hostPointsPtr = copyBytesFromCart(points, size)
+ host._null0_draw_polyline(hostPointsPtr, numPoints, hostColorPtr)
+ host._free(hostColorPtr)
+ host._free(hostPointsPtr)
+ },
+ draw_arc (centerX, centerY, radius, startAngle, endAngle, segments, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_arc(
centerX,
centerY,
@@ -236,31 +236,31 @@ export default function wireCartToHost(host, cart) {
startAngle,
endAngle,
segments,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_rectangle_rounded(x, y, width, height, cornerRadius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_rectangle_rounded (x, y, width, height, cornerRadius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_rounded(
x,
y,
width,
height,
cornerRadius,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_image(src, posX, posY) {
- host._null0_draw_image(src, posX, posY);
+ draw_image (src, posX, posY) {
+ host._null0_draw_image(src, posX, posY)
},
- draw_image_tint(src, posX, posY, tint) {
- const tintPntr = copyBytesFromCart(tint, 4);
- host._null0_draw_image_tint(src, posX, posY, tintPntr);
- host._free(tintPntr);
+ draw_image_tint (src, posX, posY, tint) {
+ const tintPntr = copyBytesFromCart(tint, 4)
+ host._null0_draw_image_tint(src, posX, posY, tintPntr)
+ host._free(tintPntr)
},
- draw_image_rotated(src, posX, posY, degrees, offsetX, offsetY, filter) {
+ draw_image_rotated (src, posX, posY, degrees, offsetX, offsetY, filter) {
host._null0_draw_image_rotated(
src,
posX,
@@ -268,16 +268,16 @@ export default function wireCartToHost(host, cart) {
degrees,
offsetX,
offsetY,
- filter,
- );
+ filter
+ )
},
- draw_image_flipped(
+ draw_image_flipped (
src,
posX,
posY,
flipHorizontal,
flipVertical,
- flipDiagonal,
+ flipDiagonal
) {
host._null0_draw_image_flipped(
src,
@@ -285,10 +285,10 @@ export default function wireCartToHost(host, cart) {
posY,
flipHorizontal,
flipVertical,
- flipDiagonal,
- );
+ flipDiagonal
+ )
},
- draw_image_scaled(
+ draw_image_scaled (
src,
posX,
posY,
@@ -296,7 +296,7 @@ export default function wireCartToHost(host, cart) {
scaleY,
offsetX,
offsetY,
- filter,
+ filter
) {
host._null0_draw_image_scaled(
src,
@@ -306,246 +306,246 @@ export default function wireCartToHost(host, cart) {
scaleY,
offsetX,
offsetY,
- filter,
- );
+ filter
+ )
},
- draw_text(font, text, posX, posY, color) {
- const textHostPtr = copyBytesFromCart(text, cartStrlen(text) + 1);
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_text(font, textHostPtr, posX, posY, hostColorPtr);
- host._free(textHostPtr);
- host._free(hostColorPtr);
+ draw_text (font, text, posX, posY, color) {
+ const textHostPtr = copyBytesFromCart(text, cartStrlen(text) + 1)
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_text(font, textHostPtr, posX, posY, hostColorPtr)
+ host._free(textHostPtr)
+ host._free(hostColorPtr)
},
- save_image(image, filename) {
+ save_image (image, filename) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- host._null0_save_image(image, filenameHostPtr);
- host._free(filenameHostPtr);
+ cartStrlen(filename) + 1
+ )
+ host._null0_save_image(image, filenameHostPtr)
+ host._free(filenameHostPtr)
},
- load_image(filename) {
+ load_image (filename) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const r = host._null0_load_image(filenameHostPtr);
- host._free(filenameHostPtr);
- return r;
- },
- image_resize(image, newWidth, newHeight, offsetX, offsetY, fill) {
- const fillPtr = copyBytesFromCart(fill, 4);
+ cartStrlen(filename) + 1
+ )
+ const r = host._null0_load_image(filenameHostPtr)
+ host._free(filenameHostPtr)
+ return r
+ },
+ image_resize (image, newWidth, newHeight, offsetX, offsetY, fill) {
+ const fillPtr = copyBytesFromCart(fill, 4)
host._null0_image_resize(
image,
newWidth,
newHeight,
offsetX,
offsetY,
- fillPtr,
- );
- host._free(fillPtr);
+ fillPtr
+ )
+ host._free(fillPtr)
},
- image_scale(image, scaleX, scaleY, filter) {
- host._null0_image_scale(image, scaleX, scaleY, filter);
+ image_scale (image, scaleX, scaleY, filter) {
+ host._null0_image_scale(image, scaleX, scaleY, filter)
},
- image_color_replace(image, color, replace) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostReplacePtr = copyBytesFromCart(replace, 4);
- host._null0_image_color_replace(image, hostColorPtr, hostReplacePtr);
- host._free(hostColorPtr);
- host._free(hostReplacePtr);
+ image_color_replace (image, color, replace) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostReplacePtr = copyBytesFromCart(replace, 4)
+ host._null0_image_color_replace(image, hostColorPtr, hostReplacePtr)
+ host._free(hostColorPtr)
+ host._free(hostReplacePtr)
},
- image_color_tint(image, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_image_color_tint(image, hostColorPtr);
- host._free(hostColorPtr);
+ image_color_tint (image, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_image_color_tint(image, hostColorPtr)
+ host._free(hostColorPtr)
},
- image_color_fade(image, alpha) {
- host._null0_image_color_fade(image, alpha);
+ image_color_fade (image, alpha) {
+ host._null0_image_color_fade(image, alpha)
},
- font_copy(font) {
- return host._null0_font_copy(font);
+ font_copy (font) {
+ return host._null0_font_copy(font)
},
- font_scale(font, scaleX, scaleY, filter) {
- return host._null0_font_scale(font, scaleX, scaleY, filter);
+ font_scale (font, scaleX, scaleY, filter) {
+ return host._null0_font_scale(font, scaleX, scaleY, filter)
},
- load_font_bmf(filename, characters) {
+ load_font_bmf (filename, characters) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
+ cartStrlen(filename) + 1
+ )
const charactersHostPtr = copyBytesFromCart(
characters,
- cartStrlen(characters) + 1,
- );
- const r = host._null0_load_font_bmf(filenameHostPtr, charactersHostPtr);
- host._free(filenameHostPtr);
- host._free(charactersHostPtr);
- return r;
- },
- load_font_bmf_from_image(image, characters) {
+ cartStrlen(characters) + 1
+ )
+ const r = host._null0_load_font_bmf(filenameHostPtr, charactersHostPtr)
+ host._free(filenameHostPtr)
+ host._free(charactersHostPtr)
+ return r
+ },
+ load_font_bmf_from_image (image, characters) {
const charactersHostPtr = copyBytesFromCart(
characters,
- cartStrlen(characters) + 1,
- );
- const r = host._null0_load_font_bmf_from_image(image, charactersHostPtr);
- host._free(charactersHostPtr);
- return r;
- },
- measure_text(retPtr, font, text) {
- const textHostPtr = copyBytesFromCart(text, cartStrlen(text));
- const retHostPtr = host._malloc(8);
- host._null0_measure_text(retHostPtr, font, textHostPtr);
- copyBytesToCart(retHostPtr, 8, retPtr);
- host._free(textHostPtr);
- host._free(retHostPtr);
- },
- measure_image(retPtr, image) {
- const retHostPtr = host._malloc(8);
- host._null0_measure_image(retHostPtr, image);
- copyBytesToCart(retHostPtr, 8, retPtr);
- host._free(retHostPtr);
- },
- load_font_tty(filename, glyphWidth, glyphHeight, characters) {
+ cartStrlen(characters) + 1
+ )
+ const r = host._null0_load_font_bmf_from_image(image, charactersHostPtr)
+ host._free(charactersHostPtr)
+ return r
+ },
+ measure_text (retPtr, font, text) {
+ const textHostPtr = copyBytesFromCart(text, cartStrlen(text))
+ const retHostPtr = host._malloc(8)
+ host._null0_measure_text(retHostPtr, font, textHostPtr)
+ copyBytesToCart(retHostPtr, 8, retPtr)
+ host._free(textHostPtr)
+ host._free(retHostPtr)
+ },
+ measure_image (retPtr, image) {
+ const retHostPtr = host._malloc(8)
+ host._null0_measure_image(retHostPtr, image)
+ copyBytesToCart(retHostPtr, 8, retPtr)
+ host._free(retHostPtr)
+ },
+ load_font_tty (filename, glyphWidth, glyphHeight, characters) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
+ cartStrlen(filename) + 1
+ )
const charactersHostPtr = copyBytesFromCart(
characters,
- cartStrlen(characters) + 1,
- );
+ cartStrlen(characters) + 1
+ )
const r = host._null0_load_font_tty(
filenameHostPtr,
glyphWidth,
glyphHeight,
- charactersHostPtr,
- );
- host._free(filenameHostPtr);
- host._free(charactersHostPtr);
- return r;
+ charactersHostPtr
+ )
+ host._free(filenameHostPtr)
+ host._free(charactersHostPtr)
+ return r
},
- load_font_tty_from_image(image, glyphWidth, glyphHeight, characters) {
+ load_font_tty_from_image (image, glyphWidth, glyphHeight, characters) {
const charactersHostPtr = copyBytesFromCart(
characters,
- cartStrlen(characters) + 1,
- );
+ cartStrlen(characters) + 1
+ )
const r = host._null0_load_font_tty_from_image(
image,
glyphWidth,
glyphHeight,
- charactersHostPtr,
- );
- host._free(charactersHostPtr);
- return r;
+ charactersHostPtr
+ )
+ host._free(charactersHostPtr)
+ return r
},
- load_font_ttf(filename, fontSize) {
+ load_font_ttf (filename, fontSize) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const r = host._null0_load_font_ttf(filenameHostPtr, fontSize);
- host._free(filenameHostPtr);
- return r;
+ cartStrlen(filename) + 1
+ )
+ const r = host._null0_load_font_ttf(filenameHostPtr, fontSize)
+ host._free(filenameHostPtr)
+ return r
},
- image_color_invert(image) {
- host._null0_image_color_invert(image);
+ image_color_invert (image) {
+ host._null0_image_color_invert(image)
},
- image_alpha_border(retPtr, image, threshold) {
- const retHostPtr = host._malloc(16);
- host._null0_image_alpha_border(retHostPtr, image, threshold);
- copyBytesToCart(retPtr, 16, retHostPtr);
- host._free(retHostPtr);
+ image_alpha_border (retPtr, image, threshold) {
+ const retHostPtr = host._malloc(16)
+ host._null0_image_alpha_border(retHostPtr, image, threshold)
+ copyBytesToCart(retPtr, 16, retHostPtr)
+ host._free(retHostPtr)
},
- image_crop(image, x, y, width, height) {
- host._null0_image_crop(image, x, y, width, height);
+ image_crop (image, x, y, width, height) {
+ host._null0_image_crop(image, x, y, width, height)
},
- image_alpha_crop(image, threshold) {
- host._null0_image_alpha_crop(image, threshold);
+ image_alpha_crop (image, threshold) {
+ host._null0_image_alpha_crop(image, threshold)
},
- image_color_brightness(image, factor) {
- host._null0_image_color_brightness(image, factor);
+ image_color_brightness (image, factor) {
+ host._null0_image_color_brightness(image, factor)
},
- image_flip(image, horizontal, vertical) {
- host._null0_image_flip(image, horizontal, vertical);
+ image_flip (image, horizontal, vertical) {
+ host._null0_image_flip(image, horizontal, vertical)
},
- image_color_contrast(image, contrast) {
- host._null0_image_color_contrast(image, contrast);
+ image_color_contrast (image, contrast) {
+ host._null0_image_color_contrast(image, contrast)
},
- image_alpha_mask(image, alphaMask, posX, posY) {
- host._null0_image_alpha_mask(image, alphaMask, posX, posY);
+ image_alpha_mask (image, alphaMask, posX, posY) {
+ host._null0_image_alpha_mask(image, alphaMask, posX, posY)
},
- image_rotate(image, degrees, filter) {
- host._null0_image_rotate(image, degrees, filter);
+ image_rotate (image, degrees, filter) {
+ host._null0_image_rotate(image, degrees, filter)
},
- image_gradient(width, height, topLeft, topRight, bottomLeft, bottomRight) {
- const hostTopLeftPtr = copyBytesFromCart(topLeft, 4);
- const hostTopRightPtr = copyBytesFromCart(topRight, 4);
- const hostBottomLeftPtr = copyBytesFromCart(bottomLeft, 4);
- const hostBottomRightPtr = copyBytesFromCart(bottomRight, 4);
+ image_gradient (width, height, topLeft, topRight, bottomLeft, bottomRight) {
+ const hostTopLeftPtr = copyBytesFromCart(topLeft, 4)
+ const hostTopRightPtr = copyBytesFromCart(topRight, 4)
+ const hostBottomLeftPtr = copyBytesFromCart(bottomLeft, 4)
+ const hostBottomRightPtr = copyBytesFromCart(bottomRight, 4)
const r = host._null0_image_gradient(
width,
height,
hostTopLeftPtr,
hostTopRightPtr,
hostBottomLeftPtr,
- hostBottomRightPtr,
- );
- host._free(hostTopLeftPtr);
- host._free(hostTopRightPtr);
- host._free(hostBottomLeftPtr);
- host._free(hostBottomRightPtr);
- return r;
- },
- unload_image(image) {
- host._null0_unload_image(image);
- },
- unload_font(font) {
- host._null0_unload_font(font);
- },
- clear_on_image(destination, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_clear_on_image(destination, hostColorPtr);
- host._free(hostColorPtr);
- },
- draw_point_on_image(destination, x, y, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_point_on_image(destination, x, y, hostColorPtr);
- host._free(hostColorPtr);
- },
- draw_line_on_image(
+ hostBottomRightPtr
+ )
+ host._free(hostTopLeftPtr)
+ host._free(hostTopRightPtr)
+ host._free(hostBottomLeftPtr)
+ host._free(hostBottomRightPtr)
+ return r
+ },
+ unload_image (image) {
+ host._null0_unload_image(image)
+ },
+ unload_font (font) {
+ host._null0_unload_font(font)
+ },
+ clear_on_image (destination, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_clear_on_image(destination, hostColorPtr)
+ host._free(hostColorPtr)
+ },
+ draw_point_on_image (destination, x, y, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_point_on_image(destination, x, y, hostColorPtr)
+ host._free(hostColorPtr)
+ },
+ draw_line_on_image (
destination,
startPosX,
startPosY,
endPosX,
endPosY,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_line_on_image(
destination,
startPosX,
startPosY,
endPosX,
endPosY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_rectangle_on_image(destination, posX, posY, width, height, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_rectangle_on_image (destination, posX, posY, width, height, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_on_image(
destination,
posX,
posY,
width,
height,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_triangle_on_image(destination, x1, y1, x2, y2, x3, y3, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_triangle_on_image (destination, x1, y1, x2, y2, x3, y3, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_triangle_on_image(
destination,
x1,
@@ -554,76 +554,76 @@ export default function wireCartToHost(host, cart) {
y2,
x3,
y3,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_ellipse_on_image(
+ draw_ellipse_on_image (
destination,
centerX,
centerY,
radiusX,
radiusY,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_ellipse_on_image(
destination,
centerX,
centerY,
radiusX,
radiusY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_circle_on_image(destination, centerX, centerY, radius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_circle_on_image (destination, centerX, centerY, radius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_circle_on_image(
destination,
centerX,
centerY,
radius,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- },
- draw_polygon_on_image(destination, points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const size = numPoints * 8;
- const hostPointsPtr = copyBytesFromCart(points, size);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ },
+ draw_polygon_on_image (destination, points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const size = numPoints * 8
+ const hostPointsPtr = copyBytesFromCart(points, size)
host._null0_draw_polygon_on_image(
destination,
hostPointsPtr,
numPoints,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- host._free(hostPointsPtr);
- },
- draw_polyline_on_image(destination, points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const size = numPoints * 8;
- const hostPointsPtr = copyBytesFromCart(points, size);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ host._free(hostPointsPtr)
+ },
+ draw_polyline_on_image (destination, points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const size = numPoints * 8
+ const hostPointsPtr = copyBytesFromCart(points, size)
host._null0_draw_polyline_on_image(
destination,
hostPointsPtr,
numPoints,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- host._free(hostPointsPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ host._free(hostPointsPtr)
},
- draw_rectangle_rounded_on_image(
+ draw_rectangle_rounded_on_image (
destination,
x,
y,
width,
height,
cornerRadius,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_rounded_on_image(
destination,
x,
@@ -631,24 +631,24 @@ export default function wireCartToHost(host, cart) {
width,
height,
cornerRadius,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_image_on_image(destination, src, posX, posY) {
- host._null0_draw_image_on_image(destination, src, posX, posY);
+ draw_image_on_image (destination, src, posX, posY) {
+ host._null0_draw_image_on_image(destination, src, posX, posY)
},
- draw_image_tint_on_image(destination, src, posX, posY, tint) {
- const hostTintPtr = copyBytesFromCart(tint, 4);
+ draw_image_tint_on_image (destination, src, posX, posY, tint) {
+ const hostTintPtr = copyBytesFromCart(tint, 4)
host._null0_draw_image_tint_on_image(
destination,
src,
posX,
posY,
- hostTintPtr,
- );
+ hostTintPtr
+ )
},
- draw_image_rotated_on_image(
+ draw_image_rotated_on_image (
destination,
src,
posX,
@@ -656,7 +656,7 @@ export default function wireCartToHost(host, cart) {
degrees,
offsetX,
offsetY,
- filter,
+ filter
) {
host._null0_draw_image_rotated_on_image(
destination,
@@ -666,17 +666,17 @@ export default function wireCartToHost(host, cart) {
degrees,
offsetX,
offsetY,
- filter,
- );
+ filter
+ )
},
- draw_image_flipped_on_image(
+ draw_image_flipped_on_image (
destination,
src,
posX,
posY,
flipHorizontal,
flipVertical,
- flipDiagonal,
+ flipDiagonal
) {
host._null0_draw_image_flipped_on_image(
destination,
@@ -685,10 +685,10 @@ export default function wireCartToHost(host, cart) {
posY,
flipHorizontal,
flipVertical,
- flipDiagonal,
- );
+ flipDiagonal
+ )
},
- draw_image_scaled_on_image(
+ draw_image_scaled_on_image (
destination,
src,
posX,
@@ -697,7 +697,7 @@ export default function wireCartToHost(host, cart) {
scaleY,
offsetX,
offsetY,
- filter,
+ filter
) {
host._null0_draw_image_scaled_on_image(
destination,
@@ -708,70 +708,70 @@ export default function wireCartToHost(host, cart) {
scaleY,
offsetX,
offsetY,
- filter,
- );
+ filter
+ )
},
- draw_text_on_image(destination, font, text, posX, posY, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const textHostPtr = copyBytesFromCart(text, cartStrlen(text) + 1);
+ draw_text_on_image (destination, font, text, posX, posY, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const textHostPtr = copyBytesFromCart(text, cartStrlen(text) + 1)
host._null0_draw_text_on_image(
destination,
font,
textHostPtr,
posX,
posY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- host._free(textHostPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ host._free(textHostPtr)
},
- draw_rectangle_outline(posX, posY, width, height, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_rectangle_outline (posX, posY, width, height, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_outline(
posX,
posY,
width,
height,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_triangle_outline(x1, y1, x2, y2, x3, y3, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_triangle_outline(x1, y1, x2, y2, x3, y3, hostColorPtr);
- host._free(hostColorPtr);
+ draw_triangle_outline (x1, y1, x2, y2, x3, y3, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_triangle_outline(x1, y1, x2, y2, x3, y3, hostColorPtr)
+ host._free(hostColorPtr)
},
- draw_ellipse_outline(centerX, centerY, radiusX, radiusY, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_ellipse_outline (centerX, centerY, radiusX, radiusY, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_ellipse_outline(
centerX,
centerY,
radiusX,
radiusY,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- draw_circle_outline(centerX, centerY, radius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_circle_outline(centerX, centerY, radius, hostColorPtr);
- host._free(hostColorPtr);
+ draw_circle_outline (centerX, centerY, radius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_circle_outline(centerX, centerY, radius, hostColorPtr)
+ host._free(hostColorPtr)
},
- draw_polygon_outline(points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- host._null0_draw_polygon_outline(points, numPoints, color);
- host._free(hostColorPtr);
+ draw_polygon_outline (points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ host._null0_draw_polygon_outline(points, numPoints, color)
+ host._free(hostColorPtr)
},
- draw_arc_outline(
+ draw_arc_outline (
centerX,
centerY,
radius,
startAngle,
endAngle,
segments,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_arc_outline(
centerX,
centerY,
@@ -779,40 +779,40 @@ export default function wireCartToHost(host, cart) {
startAngle,
endAngle,
segments,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_rectangle_rounded_outline(x, y, width, height, cornerRadius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_rectangle_rounded_outline (x, y, width, height, cornerRadius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_rounded_outline(
x,
y,
width,
height,
cornerRadius,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_rectangle_outline_on_image(
+ draw_rectangle_outline_on_image (
destination,
posX,
posY,
width,
height,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_outline_on_image(
destination,
posX,
posY,
width,
height,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_triangle_outline_on_image(destination, x1, y1, x2, y2, x3, y3, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_triangle_outline_on_image (destination, x1, y1, x2, y2, x3, y3, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_triangle_outline_on_image(
destination,
x1,
@@ -821,60 +821,60 @@ export default function wireCartToHost(host, cart) {
y2,
x3,
y3,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_ellipse_outline_on_image(
+ draw_ellipse_outline_on_image (
destination,
centerX,
centerY,
radiusX,
radiusY,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_ellipse_outline_on_image(
destination,
centerX,
centerY,
radiusX,
radiusY,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_circle_outline_on_image(destination, centerX, centerY, radius, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ draw_circle_outline_on_image (destination, centerX, centerY, radius, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_circle_outline_on_image(
destination,
centerX,
centerY,
radius,
- hostColorPtr,
- );
+ hostColorPtr
+ )
},
- draw_polygon_outline_on_image(destination, points, numPoints, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const size = numPoints * 8;
- const hostPointsPtr = copyBytesFromCart(points, size);
+ draw_polygon_outline_on_image (destination, points, numPoints, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const size = numPoints * 8
+ const hostPointsPtr = copyBytesFromCart(points, size)
host._null0_draw_polygon_outline_on_image(
destination,
hostPointsPtr,
numPoints,
- hostColorPtr,
- );
- host._free(hostColorPtr);
- host._free(hostPointsPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
+ host._free(hostPointsPtr)
},
- draw_rectangle_rounded_outline_on_image(
+ draw_rectangle_rounded_outline_on_image (
destination,
x,
y,
width,
height,
cornerRadius,
- color,
+ color
) {
- const hostColorPtr = copyBytesFromCart(color, 4);
+ const hostColorPtr = copyBytesFromCart(color, 4)
host._null0_draw_rectangle_rounded_outline_on_image(
destination,
x,
@@ -882,132 +882,135 @@ export default function wireCartToHost(host, cart) {
width,
height,
cornerRadius,
- hostColorPtr,
- );
- host._free(hostColorPtr);
+ hostColorPtr
+ )
+ host._free(hostColorPtr)
},
- file_read(filename, bytesRead) {
- const filenameHostPtr = copyBytesFromCart(
- filename,
- cartStrlen(filename) + 1,
- );
- const bytesHostPtr = host._malloc(4);
- const retPtr = host._null0_file_read(filenameHostPtr, bytesHostPtr);
- const r = copyBytesToCart(retPtr, host.HEAPU32[bytesHostPtr / 4]);
- copyBytesToCart(bytesHostPtr, 4, bytesRead);
- host._free(filenameHostPtr);
- host._free(bytesHostPtr);
- return r;
- },
- file_write(filename, data, byteSize) {
+ file_read (filename, wasmBytesReadPtr, wasmRetPtr) {
+ // copy filename from cart to host
+ const filenameHostPtr = copyBytesFromCart(filename, cartStrlen(filename) + 1)
+
+ // get size of file
+ const fileInfoHostPtr = host._malloc(40)
+ host._null0_file_info(fileInfoHostPtr, filenameHostPtr)
+ const filesize = host.HEAPU32[fileInfoHostPtr / 4]
+
+ // setup cart-pointer for bytesRead/ret
+ const bytesReadHostPtr = host._malloc(4)
+ const retPtr = host._malloc(filesize)
+
+ host._null0_file_read(filenameHostPtr, bytesReadHostPtr, retPtr)
+ copyBytesToCart(retPtr, wasmRetPtr, filesize)
+ },
+ file_write (filename, data, byteSize) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const bytesHostPtr = copyBytesFromCart(data, byteSize);
- copyBytesFromCart(bytesHostPtr, byteSize, data);
- const r = host._null0_file_write(filenameHostPtr, bytesHostPtr, byteSize);
- host._free(filenameHostPtr);
- host._free(bytesHostPtr);
- return r;
- },
- file_append(filename, data, byteSize) {
+ cartStrlen(filename) + 1
+ )
+ const bytesHostPtr = copyBytesFromCart(data, byteSize)
+ copyBytesFromCart(bytesHostPtr, byteSize, data)
+ const r = host._null0_file_write(filenameHostPtr, bytesHostPtr, byteSize)
+ host._free(filenameHostPtr)
+ host._free(bytesHostPtr)
+ return r
+ },
+ file_append (filename, data, byteSize) {
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- const bytesHostPtr = copyBytesFromCart(data, byteSize);
- copyBytesFromCart(bytesHostPtr, byteSize, data);
+ cartStrlen(filename) + 1
+ )
+ const bytesHostPtr = copyBytesFromCart(data, byteSize)
+ copyBytesFromCart(bytesHostPtr, byteSize, data)
const r = host._null0_file_append(
filenameHostPtr,
bytesHostPtr,
- byteSize,
- );
- host._free(filenameHostPtr);
- host._free(bytesHostPtr);
- return r;
- },
- file_info(retPtr, filename) {
- const retHostPtr = host._malloc(40);
+ byteSize
+ )
+ host._free(filenameHostPtr)
+ host._free(bytesHostPtr)
+ return r
+ },
+ file_info (retPtr, filename) {
+ const retHostPtr = host._malloc(40)
const filenameHostPtr = copyBytesFromCart(
filename,
- cartStrlen(filename) + 1,
- );
- host._null0_file_info(retHostPtr, filenameHostPtr);
- copyBytesToCart(retHostPtr, 40, retPtr);
- host._free(retHostPtr);
- host._free(filenameHostPtr);
- },
- get_write_dir() {
- const hostRetPtr = host._null0_get_write_dir();
- return copyBytesToCart(hostRetPtr, hostStrlen(hostRetPtr));
- },
- color_tint(retPtr, color, tint) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostTintPtr = copyBytesFromCart(tint, 4);
- const hostRetPtr = host._malloc(4);
- host._null0_color_tint(hostRetPtr, hostColorPtr, hostTintPtr);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostColorPtr);
- host._free(hostTintPtr);
- host._free(hostRetPtr);
- },
- color_fade(retPtr, color, alpha) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostRetPtr = host.malloc(4);
- host._null0_color_fade(hostRetPtr, hostColorPtr, alpha);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostColorPtr);
- host._free(hostRetPtr);
- },
- color_brightness(retPtr, color, factor) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostRetPtr = host.malloc(4);
- host._null0_color_brightness(hostRetPtr, hostColorPtr, factor);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostColorPtr);
- host._free(hostRetPtr);
- },
- color_invert(retPtr, color) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostRetPtr = host.malloc(4);
- host._null0_color_invert(hostRetPtr, hostColorPtr);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostColorPtr);
- host._free(hostRetPtr);
- },
- color_alpha_blend(retPtr, dst, src) {
- const hostDstPtr = copyBytesFromCart(dst, 4);
- const hostSrcPtr = copyBytesFromCart(src, 4);
- const hostRetPtr = host.malloc(4);
- host._null0_color_alpha_blend(hostRetPtr, hostDstPtr, hostSrcPtr);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostDstPtr);
- host._free(hostSrcPtr);
- host._free(hostRetPtr);
- },
- color_contrast(retPtr, color, contrast) {
- const hostColorPtr = copyBytesFromCart(color, 4);
- const hostRetPtr = host.malloc(4);
- host._null0_color_contrast(hostRetPtr, hostColorPtr, contrast);
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostColorPtr);
- host._free(hostRetPtr);
- },
- color_bilinear_interpolate(
+ cartStrlen(filename) + 1
+ )
+ host._null0_file_info(retHostPtr, filenameHostPtr)
+ copyBytesToCart(retHostPtr, 40, retPtr)
+ host._free(retHostPtr)
+ host._free(filenameHostPtr)
+ },
+ get_write_dir () {
+ const hostRetPtr = host._null0_get_write_dir()
+ return copyBytesToCart(hostRetPtr, hostStrlen(hostRetPtr))
+ },
+ color_tint (retPtr, color, tint) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostTintPtr = copyBytesFromCart(tint, 4)
+ const hostRetPtr = host._malloc(4)
+ host._null0_color_tint(hostRetPtr, hostColorPtr, hostTintPtr)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostColorPtr)
+ host._free(hostTintPtr)
+ host._free(hostRetPtr)
+ },
+ color_fade (retPtr, color, alpha) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostRetPtr = host.malloc(4)
+ host._null0_color_fade(hostRetPtr, hostColorPtr, alpha)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostColorPtr)
+ host._free(hostRetPtr)
+ },
+ color_brightness (retPtr, color, factor) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostRetPtr = host.malloc(4)
+ host._null0_color_brightness(hostRetPtr, hostColorPtr, factor)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostColorPtr)
+ host._free(hostRetPtr)
+ },
+ color_invert (retPtr, color) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostRetPtr = host.malloc(4)
+ host._null0_color_invert(hostRetPtr, hostColorPtr)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostColorPtr)
+ host._free(hostRetPtr)
+ },
+ color_alpha_blend (retPtr, dst, src) {
+ const hostDstPtr = copyBytesFromCart(dst, 4)
+ const hostSrcPtr = copyBytesFromCart(src, 4)
+ const hostRetPtr = host.malloc(4)
+ host._null0_color_alpha_blend(hostRetPtr, hostDstPtr, hostSrcPtr)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostDstPtr)
+ host._free(hostSrcPtr)
+ host._free(hostRetPtr)
+ },
+ color_contrast (retPtr, color, contrast) {
+ const hostColorPtr = copyBytesFromCart(color, 4)
+ const hostRetPtr = host.malloc(4)
+ host._null0_color_contrast(hostRetPtr, hostColorPtr, contrast)
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostColorPtr)
+ host._free(hostRetPtr)
+ },
+ color_bilinear_interpolate (
retPtr,
color00,
color01,
color10,
color11,
coordinateX,
- coordinateY,
+ coordinateY
) {
- const hostColor00Ptr = copyBytesFromCart(color00, 4);
- const hostColor01Ptr = copyBytesFromCart(color01, 4);
- const hostColor10Ptr = copyBytesFromCart(color10, 4);
- const hostColor11Ptr = copyBytesFromCart(color11, 4);
- const hostRetPtr = host.malloc(4);
+ const hostColor00Ptr = copyBytesFromCart(color00, 4)
+ const hostColor01Ptr = copyBytesFromCart(color01, 4)
+ const hostColor10Ptr = copyBytesFromCart(color10, 4)
+ const hostColor11Ptr = copyBytesFromCart(color11, 4)
+ const hostRetPtr = host.malloc(4)
host._null0_color_bilinear_interpolate(
hostRetPtr,
hostColor00Ptr,
@@ -1015,10 +1018,10 @@ export default function wireCartToHost(host, cart) {
hostColor10Ptr,
hostColor11Ptr,
coordinateX,
- coordinateY,
- );
- copyBytesToCart(hostRetPtr, 4, retPtr);
- host._free(hostRetPtr);
- },
- };
+ coordinateY
+ )
+ copyBytesToCart(hostRetPtr, 4, retPtr)
+ host._free(hostRetPtr)
+ }
+ }
}
diff --git a/docs/null0_wc.js b/docs/null0_wc.js
index fda8545..3e80670 100644
--- a/docs/null0_wc.js
+++ b/docs/null0_wc.js
@@ -1,9 +1,10 @@
// this will setup the web-component
+/* global HTMLElement */
import setupCart from './null0.js'
export default class Null0WebComponent extends HTMLElement {
- constructor() {
+ constructor () {
super()
this.shadow = this.attachShadow({ mode: 'open' })
this.canvas = document.createElement('canvas')
@@ -13,12 +14,12 @@ export default class Null0WebComponent extends HTMLElement {
throw new Error('src attribute is required, and should point to your cart URL.')
}
- setupCart(this.attributes.src.value, this.canvas).then(({host, cart}) => {
+ setupCart(this.attributes.src.value, this.canvas).then(({ host, cart }) => {
this.host = host
this.cart = cart
if (this.attributes?.fps) {
const ctx = this.host.canvas.getContext('2d')
- ctx.font = "16px Arial"
+ ctx.font = '16px Arial'
let t = Date.now()
let o = t
let d = 0
@@ -28,10 +29,10 @@ export default class Null0WebComponent extends HTMLElement {
if (t - o > updateTime) {
d = Date.now() - t
o = t
- fps = parseInt(1000/d)
+ fps = parseInt(1000 / d)
}
t = Date.now()
-
+
ctx.fillStyle = 'black'
ctx.fillText(fps, 9, 19)
ctx.fillStyle = 'black'
@@ -46,4 +47,4 @@ export default class Null0WebComponent extends HTMLElement {
document.addEventListener('DOMContentLoaded', () => {
window.customElements.define('null0-cart', Null0WebComponent)
-})
\ No newline at end of file
+})