Compare commits
No commits in common. "082fbf3e8067d4456c33521c36fd7a83f7339e23" and "c49b042b62ab84f173b737339a016e2a523c78e8" have entirely different histories.
082fbf3e80
...
c49b042b62
@ -11,7 +11,7 @@ pub(crate) fn integrate(linker: &mut Linker<ExecutorState>) -> VResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn yield_frame(_caller: Caller<ExecutorState>) -> Result<(), Trap> {
|
||||
fn yield_frame(caller: Caller<ExecutorState>) -> Result<(), Trap> {
|
||||
Err(Trap::from(YieldFrame {}))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::mem;
|
||||
use std::{fmt::Display, mem};
|
||||
|
||||
use viperid::VResult;
|
||||
use wasmi::{core::Trap, Engine, Linker, Module, Store, TypedFunc, TypedResumableCall, TypedResumableInvocation};
|
||||
use wasmi::{core::{HostError, Trap}, Engine, Linker, Module, Store, TypedFunc, TypedResumableCall, TypedResumableInvocation};
|
||||
|
||||
use crate::{engine_api::{self, YieldFrame}, wasi::{self, StockWasi}};
|
||||
|
||||
@ -34,7 +34,7 @@ impl Executor {
|
||||
|
||||
let mut linker = <Linker<ExecutorState>>::new(&engine);
|
||||
wasi::integrate(&mut linker, |hs| &mut hs.wasi)?;
|
||||
engine_api::integrate(&mut linker)?;
|
||||
engine_api::integrate(&mut linker);
|
||||
|
||||
let instance = linker
|
||||
.instantiate(&mut store, &module)?
|
||||
|
@ -149,11 +149,6 @@ function generateColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
function clamp(x) {
|
||||
if (x < 0.0) { return 0.0; }
|
||||
if (x > 255.0) { return 255.0; }
|
||||
return Math.round(x);
|
||||
}
|
||||
|
||||
function dump(fname, colors, width, height, scalar) {
|
||||
if (colors.length != width * height) {
|
||||
@ -161,6 +156,12 @@ function dump(fname, colors, width, height, scalar) {
|
||||
}
|
||||
let pngdata = [];
|
||||
|
||||
let clamp = function(x) {
|
||||
if (x < 0.0) { return 0.0; }
|
||||
if (x > 255.0) { return 255.0; }
|
||||
return Math.round(x);
|
||||
}
|
||||
|
||||
for (var y = 0; y < height * scalar; y++) {
|
||||
for (var x = 0; x < width * scalar; x++) {
|
||||
let i = Math.floor(y / scalar) * width + Math.floor(x / scalar);
|
||||
@ -180,21 +181,4 @@ function dump(fname, colors, width, height, scalar) {
|
||||
png.pack().pipe(fs.createWriteStream(fname));
|
||||
}
|
||||
|
||||
function dumpRust(fname, colors) {
|
||||
var paletteString = "";
|
||||
paletteString += "pub const PALETTE: [[u8; 3]; " + palette.length + "] = [\n"
|
||||
for (var i = 0; i < colors.length; i++) {
|
||||
var c = colors[i];
|
||||
paletteString += (" [" +
|
||||
clamp(255 * c.srgb.r) + ", " +
|
||||
clamp(255 * c.srgb.g) + ", " +
|
||||
clamp(255 * c.srgb.b) +
|
||||
"],\n");
|
||||
}
|
||||
paletteString += "];\n"
|
||||
fs.writeFileSync(fname, paletteString);
|
||||
}
|
||||
|
||||
var palette = generateColors();
|
||||
dump("palette.png", palette, 8, 8, 64);
|
||||
dumpRust("../../src/palette.rs", palette)
|
||||
dump("palette.png", generateColors(), 8, 8, 64);
|
@ -1,4 +1 @@
|
||||
mod palette;
|
||||
|
||||
pub use palette::PALETTE;
|
||||
pub type VResult<T> = Result<T, anyhow::Error>;
|
||||
|
@ -1,66 +0,0 @@
|
||||
pub const PALETTE: [[u8; 3]; 64] = [
|
||||
[0, 0, 0],
|
||||
[0, 0, 255],
|
||||
[0, 255, 0],
|
||||
[0, 255, 255],
|
||||
[255, 0, 0],
|
||||
[255, 0, 255],
|
||||
[255, 255, 0],
|
||||
[255, 255, 255],
|
||||
[32, 45, 44],
|
||||
[41, 60, 67],
|
||||
[18, 22, 32],
|
||||
[40, 34, 49],
|
||||
[27, 17, 29],
|
||||
[54, 42, 47],
|
||||
[46, 33, 23],
|
||||
[66, 60, 43],
|
||||
[39, 92, 148],
|
||||
[55, 83, 107],
|
||||
[110, 45, 90],
|
||||
[79, 50, 74],
|
||||
[130, 103, 52],
|
||||
[100, 85, 68],
|
||||
[80, 133, 85],
|
||||
[88, 106, 80],
|
||||
[59, 115, 206],
|
||||
[76, 108, 153],
|
||||
[165, 53, 114],
|
||||
[124, 70, 99],
|
||||
[188, 157, 22],
|
||||
[154, 137, 89],
|
||||
[57, 194, 137],
|
||||
[109, 161, 129],
|
||||
[39, 187, 255],
|
||||
[123, 67, 240],
|
||||
[186, 66, 177],
|
||||
[239, 60, 80],
|
||||
[255, 170, 48],
|
||||
[186, 255, 0],
|
||||
[69, 255, 115],
|
||||
[2, 241, 228],
|
||||
[150, 190, 255],
|
||||
[185, 113, 226],
|
||||
[220, 118, 175],
|
||||
[249, 134, 85],
|
||||
[242, 204, 114],
|
||||
[194, 255, 116],
|
||||
[100, 255, 173],
|
||||
[105, 242, 252],
|
||||
[201, 169, 248],
|
||||
[221, 193, 228],
|
||||
[250, 156, 143],
|
||||
[240, 197, 180],
|
||||
[230, 237, 137],
|
||||
[233, 243, 193],
|
||||
[116, 253, 234],
|
||||
[182, 247, 242],
|
||||
[243, 222, 238],
|
||||
[237, 228, 236],
|
||||
[254, 235, 224],
|
||||
[245, 241, 240],
|
||||
[245, 254, 225],
|
||||
[250, 253, 246],
|
||||
[211, 250, 250],
|
||||
[230, 247, 244],
|
||||
];
|
Loading…
Reference in New Issue
Block a user