build
This commit is contained in:
parent
4baabc0a20
commit
d477782ff6
Binary file not shown.
|
@ -121,25 +121,15 @@ function command_to_state (prev_state, curr_command) {
|
||||||
return {...prev_state, penwidth: width}
|
return {...prev_state, penwidth: width}
|
||||||
}
|
}
|
||||||
case "pencolor": {
|
case "pencolor": {
|
||||||
if (curr_command.length = 2) {
|
const [_, color] = curr_command
|
||||||
const [_, color] = curr_command
|
return {...prev_state, pencolor: color}
|
||||||
return {...prev_state, pencolor: color}
|
|
||||||
} else {
|
|
||||||
const [_, r, g, b, a] = curr_command
|
|
||||||
return {...prev_state, pencolor: [r, g, b, a]}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "setheading": {
|
case "setheading": {
|
||||||
const [_, heading] = curr_command
|
const [_, heading] = curr_command
|
||||||
return {...prev_state, heading: heading}
|
return {...prev_state, heading: heading}
|
||||||
}
|
}
|
||||||
case "loadstate": {
|
case "loadstate": {
|
||||||
const [_, x, y, heading, visible, pendown, penwidth] = curr_command
|
const [_, x, y, heading, visible, pendown, penwidth, pencolor] = curr_command
|
||||||
// there are 7 fixed-arity arguments
|
|
||||||
// color will either be the last one or four
|
|
||||||
let pencolor = curr_command.slice(7)
|
|
||||||
// if there's one, it's a string, unpack it
|
|
||||||
if (pencolor.length = 1) pencolor = pencolor[0]
|
|
||||||
return {position: [x, y], heading, visible, pendown, penwidth, pencolor}
|
return {position: [x, y], heading, visible, pendown, penwidth, pencolor}
|
||||||
}
|
}
|
||||||
case "show": {
|
case "show": {
|
||||||
|
@ -149,9 +139,7 @@ function command_to_state (prev_state, curr_command) {
|
||||||
return {...prev_state, visible: false}
|
return {...prev_state, visible: false}
|
||||||
}
|
}
|
||||||
case "background": {
|
case "background": {
|
||||||
let color = curr_command.slice(1)
|
background_color = curr_command.slice(1)
|
||||||
if (color.lengh = 1) color = color[0]
|
|
||||||
background_color = color
|
|
||||||
return prev_state
|
return prev_state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +332,7 @@ export function p5_calls (commands) {
|
||||||
p5_calls.push(call)
|
p5_calls.push(call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p5_calls[0] = ["background", ...resolve_color(background_color)]
|
p5_calls[0] = ["background", background_color]
|
||||||
p5_render_turtle(states[states.length - 1], p5_calls)
|
p5_render_turtle(states[states.length - 1], p5_calls)
|
||||||
return p5_calls
|
return p5_calls
|
||||||
}
|
}
|
||||||
|
|
|
@ -6489,7 +6489,7 @@ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['
|
||||||
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
|
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
|
||||||
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
|
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
|
||||||
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
|
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
|
||||||
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1819920;
|
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1816028;
|
||||||
function invoke_i(index) {
|
function invoke_i(index) {
|
||||||
var sp = stackSave();
|
var sp = stackSave();
|
||||||
try {
|
try {
|
||||||
|
|
BIN
build/out.wasm
BIN
build/out.wasm
Binary file not shown.
4024
build/svg_test.svg
4024
build/svg_test.svg
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 338 KiB After Width: | Height: | Size: 722 B |
6
justfile
6
justfile
|
@ -23,9 +23,9 @@ publish:
|
||||||
|
|
||||||
# build the ludus jimage
|
# build the ludus jimage
|
||||||
build:
|
build:
|
||||||
rm build/out.mjs
|
rm -f build/out.mjs
|
||||||
rm build/out.wasm
|
rm -f build/out.wasm
|
||||||
rm build/ludus.jimage
|
rm -f build/ludus.jimage
|
||||||
janet -c src/ludus.janet build/ludus.jimage
|
janet -c src/ludus.janet build/ludus.jimage
|
||||||
cd build && just build
|
cd build && just build
|
||||||
git commit -am "build"
|
git commit -am "build"
|
||||||
|
|
28
prelude.ld
28
prelude.ld
|
@ -1159,9 +1159,9 @@ let pd! = pendown!
|
||||||
fn pencolor! {
|
fn pencolor! {
|
||||||
"Changes the turtle's pen color. Takes a single grayscale value, an rgb tuple, or an rgba tuple. Alias: pc!"
|
"Changes the turtle's pen color. Takes a single grayscale value, an rgb tuple, or an rgba tuple. Alias: pc!"
|
||||||
(color as :keyword) -> add_command! ((:pencolor, color))
|
(color as :keyword) -> add_command! ((:pencolor, color))
|
||||||
(gray as :number) -> add_command! ((:pencolor, gray, gray, gray, 255))
|
(gray as :number) -> add_command! ((:pencolor, (gray, gray, gray, 255)))
|
||||||
((r as :number, g as :number, b as :number)) -> add_command! ((:pencolor, r, g, b, 255))
|
((r as :number, g as :number, b as :number)) -> add_command! ((:pencolor, (r, g, b, 255)))
|
||||||
((r as :number, g as :number, b as :number, a as :number)) -> add_command! ((:pencolor, r, g, b, a))
|
((r as :number, g as :number, b as :number, a as :number)) -> add_command! ((:pencolor, (r, g, b, a)))
|
||||||
}
|
}
|
||||||
|
|
||||||
let pc! = pencolor!
|
let pc! = pencolor!
|
||||||
|
@ -1176,9 +1176,9 @@ let pw! = penwidth!
|
||||||
fn background! {
|
fn background! {
|
||||||
"Sets the background color behind the turtle and path. Alias: bg!"
|
"Sets the background color behind the turtle and path. Alias: bg!"
|
||||||
(color as :keyword) -> add_command! ((:background, color))
|
(color as :keyword) -> add_command! ((:background, color))
|
||||||
(gray as :number) -> add_command! ((:background, gray, gray, gray, 255))
|
(gray as :number) -> add_command! ((:background, (gray, gray, gray, 255)))
|
||||||
((r as :number, g as :number, b as :number)) -> add_command! ((:background, r, g, b, 255))
|
((r as :number, g as :number, b as :number)) -> add_command! ((:background, (r, g, b, 255)))
|
||||||
((r as :number, g as :number, b as :number, a as :number)) -> add_command! ((:background, r, g, b, a))
|
((r as :number, g as :number, b as :number, a as :number)) -> add_command! ((:background, (r, g, b, a)))
|
||||||
}
|
}
|
||||||
|
|
||||||
let bg! = background!
|
let bg! = background!
|
||||||
|
@ -1215,17 +1215,10 @@ fn hideturtle! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn loadstate! {
|
fn loadstate! {
|
||||||
"Sets the turtle state to a previously saved state. Returns the state."
|
"Sets the turtle state to a previously saved state."
|
||||||
(state) -> {
|
(state) -> {
|
||||||
let #{:position (x, y), heading, pendown?, pencolor, penwidth, visible?} = state
|
let #{position, heading, pendown?, pencolor, penwidth, visible?} = state
|
||||||
let command = if tuple? (pencolor)
|
add_command! ((:loadstate, position, heading, visible?, pendown?, penwidth, pencolor))
|
||||||
then {
|
|
||||||
let (r, g, b, a) = pencolor
|
|
||||||
(:loadstate, x, y, heading, visible?, pendown?, penwidth, r, g, b, a)
|
|
||||||
}
|
|
||||||
else (:loadstate, x, y, heading, visible?, pendown?, penwidth, pencolor)
|
|
||||||
add_command! (command)
|
|
||||||
state
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1258,8 +1251,7 @@ fn apply_command {
|
||||||
(:penwidth, pixels) -> assoc (state, :penwidth, pixels)
|
(:penwidth, pixels) -> assoc (state, :penwidth, pixels)
|
||||||
(:pencolor, color) -> assoc (state, :pencolor, color)
|
(:pencolor, color) -> assoc (state, :pencolor, color)
|
||||||
(:setheading, heading) -> assoc (state, :heading, heading)
|
(:setheading, heading) -> assoc (state, :heading, heading)
|
||||||
(:loadstate, x, y, heading, visible?, pendown?, penwidth, pencolor) -> #{:position (x, y), heading, visible?, pendown?, penwidth, pencolor}
|
(:loadstate, position, heading, visible?, pendown?, penwidth, pencolor) -> #{position, heading, visible?, pendown?, penwidth, pencolor}
|
||||||
(:loadstate, x, y, heading, visible?, pendown?, penwidth, r, g, b, a) -> #{:position (x, y), heading, visible?, pendown?, penwidth, :pencolor (r, g, b, a)}
|
|
||||||
(:show) -> assoc (state, :visible?, true)
|
(:show) -> assoc (state, :visible?, true)
|
||||||
(:hide) -> assoc (state, :visible?, false)
|
(:hide) -> assoc (state, :visible?, false)
|
||||||
(:background, _) -> state
|
(:background, _) -> state
|
||||||
|
|
Loading…
Reference in New Issue
Block a user