build
This commit is contained in:
parent
066edb00b5
commit
2f5557a552
Binary file not shown.
|
@ -10,6 +10,7 @@ export function run (source) {
|
|||
code = source
|
||||
const output = mod.ludus(source).value
|
||||
res = JSON.parse(output)
|
||||
console.log(res)
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -134,7 +135,8 @@ function command_to_state (prev_state, curr_command) {
|
|||
return {...prev_state, heading: heading}
|
||||
}
|
||||
case "loadstate": {
|
||||
const [_, x, y, heading, visible, pendown, penwidth, pencolor] = curr_command
|
||||
console.log("LOADSTATE: ", curr_command)
|
||||
const [_, [x, y], heading, visible, pendown, penwidth, pencolor] = curr_command
|
||||
return {position: [x, y], heading, visible, pendown, penwidth, pencolor}
|
||||
}
|
||||
case "show": {
|
||||
|
@ -276,12 +278,14 @@ function svg_render_turtle (state) {
|
|||
}
|
||||
|
||||
export function svg (commands) {
|
||||
console.log(commands)
|
||||
const states = [turtle_init]
|
||||
commands.reduce((prev_state, command) => {
|
||||
const new_state = command_to_state(prev_state, command)
|
||||
states.push(new_state)
|
||||
return new_state
|
||||
}, turtle_init)
|
||||
console.log(states)
|
||||
const {maxX, maxY, minX, minY} = states.reduce((accum, {position: [x, y]}) => {
|
||||
accum.maxX = Math.max(accum.maxX, x)
|
||||
accum.maxY = Math.max(accum.maxY, y)
|
||||
|
|
|
@ -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 ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
|
||||
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
|
||||
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1820168;
|
||||
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1819972;
|
||||
function invoke_i(index) {
|
||||
var sp = stackSave();
|
||||
try {
|
||||
|
|
BIN
build/out.wasm
BIN
build/out.wasm
Binary file not shown.
|
@ -4,8 +4,6 @@ const code = `
|
|||
|
||||
let home = unbox (turtle_state)
|
||||
|
||||
fd! (100)
|
||||
rt! (0.25)
|
||||
fd! (100)
|
||||
|
||||
loadstate! (home)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="background-color:rgb(0 0 0); background-opacity: 1" viewBox="NaN NaN NaN 120">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="background-color:rgb(0 0 0); background-opacity: 1" viewBox="-12 -112 120 120">
|
||||
|
||||
<g transform="scale(-1, 1) rotate(180)">
|
||||
|
||||
|
@ -7,14 +7,12 @@
|
|||
|
||||
<line x1="6.123233995736766e-15" y1="100" x2="100" y2="100" stroke="rgb(255 255 255)" stroke-opacity="1" stroke-width="1"/>
|
||||
|
||||
<line x1="100" y1="100" x2="0,0" y2="0" stroke="rgb(255 255 255)" stroke-opacity="1" stroke-width="1"/>
|
||||
|
||||
<line x1="0,0" y1="0" x2="0,0100" y2="0" stroke="rgb(0 0 0)" stroke-opacity="1" stroke-width="white"/>
|
||||
<line x1="100" y1="100" x2="100" y2="0" stroke="rgb(255 255 255)" stroke-opacity="1" stroke-width="1"/>
|
||||
|
||||
|
||||
<g transform="translate(0,0100, 0)rotate(90)">
|
||||
<g transform="translate(100, 0)rotate(180)">
|
||||
<polygon points="0 20 -13.226237306473037 -15.00222139260919 13.226237306473037 -15.00222139260919" stroke="none" fill="rgb(255 255 255)" fill-opacity="0.5882352941176471"/>
|
||||
<line x1="0" y1="20" x2="0" y2="0" stroke="rgb(0 0 0)" stroke-opacity="1" stroke-width="white" />
|
||||
<line x1="0" y1="20" x2="0" y2="0" stroke="rgb(255 255 255)" stroke-opacity="1" stroke-width="1" />
|
||||
</g>
|
||||
|
||||
</g>
|
||||
|
@ -28,7 +26,7 @@ fd! (100)
|
|||
rt! (0.25)
|
||||
fd! (100)
|
||||
|
||||
loadstate! (home)
|
||||
& loadstate! (home)
|
||||
|
||||
rt! (0.25)
|
||||
fd! (100)
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -1227,8 +1227,8 @@ fn hideturtle! {
|
|||
fn loadstate! {
|
||||
"Sets the turtle state to a previously saved state."
|
||||
(state) -> {
|
||||
let #{:position (x, y), heading, pendown?, pencolor, penwidth, visible?} = state
|
||||
add_command! ((:loadstate, x, y, heading, visible?, pendown?, penwidth, pencolor))
|
||||
let #{position, heading, pendown?, pencolor, penwidth, visible?} = state
|
||||
add_command! ((:loadstate, position, heading, visible?, pendown?, penwidth, pencolor))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user