fix svg typo bug
This commit is contained in:
parent
a86041ed66
commit
6a71e3c244
|
@ -309,7 +309,7 @@ export function svg (commands) {
|
||||||
const path = svg_render_path(states)
|
const path = svg_render_path(states)
|
||||||
const turtle = svg_render_turtle(states[states.length - 1])
|
const turtle = svg_render_turtle(states[states.length - 1])
|
||||||
return `<?xml version="1.0" standalone="no"?>
|
return `<?xml version="1.0" standalone="no"?>
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${x_origin} ${y_origin} ${view_width} ${view_height}" width="10in", height="8in">
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${x_origin} ${y_origin} ${view_width} ${view_height}" width="10in" height="8in">
|
||||||
|
|
||||||
<rect x="${x_origin - 5}" y="${y_origin - 5}" width="${view_width + 10}" height="${view_height + 10}" fill="#${hex(r)}${hex(g)}${hex(b)}" stroke-width="0" paint-order="fill" />
|
<rect x="${x_origin - 5}" y="${y_origin - 5}" width="${view_width + 10}" height="${view_height + 10}" fill="#${hex(r)}${hex(g)}${hex(b)}" stroke-width="0" paint-order="fill" />
|
||||||
|
|
||||||
|
|
|
@ -1,66 +1,33 @@
|
||||||
import {run, svg, stdout} from "./ludus.mjs"
|
import {run, svg, stdout} from "./ludus.mjs"
|
||||||
|
|
||||||
const code = `
|
const code = `
|
||||||
background! (colors :white)
|
penwidth!(7)
|
||||||
pencolor! (colors :maroon)
|
pencolor!(:red)
|
||||||
|
background!(:maroon)
|
||||||
|
|
||||||
fn ngon! (n, edge) -> {
|
fn ngon! (num_sides, side_len) -> {
|
||||||
repeat n {
|
repeat num_sides {
|
||||||
forward! (edge)
|
forward! (side_len)
|
||||||
right! (inv (n))
|
right! (inv (num_sides))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cngon! (n, radius) -> {
|
fn show_gons! (n, side_len) -> {
|
||||||
let angle = add (inv (4), inv (mult (2, n)))
|
if lte? (n, 0)
|
||||||
let edge = mult (2, radius, sin (inv (mult (2, n))))
|
then :ok
|
||||||
|
else {
|
||||||
|
ngon! (n, side_len)
|
||||||
penup!()
|
penup!()
|
||||||
forward! (radius)
|
rt!(0.01)
|
||||||
right! (angle)
|
fd!(add (side_len, 10))
|
||||||
pendown!()
|
pendown!()
|
||||||
ngon! (n, edge)
|
show_gons! (sub (n, 1), side_len)
|
||||||
left! (angle)
|
|
||||||
penup! ()
|
|
||||||
back! (radius)
|
|
||||||
pendown! ()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn twisty_nonagons! (times, iter, radius, growth) -> {
|
|
||||||
if gte? (iter, times) then :ok
|
|
||||||
else {
|
|
||||||
cngon! (9, radius)
|
|
||||||
right! (inv (times))
|
|
||||||
twisty_nonagons! (times, inc (iter), add (radius, growth), growth)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
twisty_nonagons! (10, 0, 100, 3)
|
show_gons! (100, 100)
|
||||||
|
|
||||||
fn centre_squares! (times, radius, growth) -> {
|
hideturtle!()
|
||||||
if lt? (times, 1) then :ok
|
|
||||||
else {
|
|
||||||
cngon! (4, radius)
|
|
||||||
centre_squares! (dec (times), add (radius, growth), growth)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
& right! (0.125)
|
|
||||||
& centre_squares! (10, 100, 4)
|
|
||||||
|
|
||||||
fn twisty_triangles! (times, radius, angle, growth) -> {
|
|
||||||
if lt? (times, 1) then :ok
|
|
||||||
else {
|
|
||||||
cngon! (3, radius)
|
|
||||||
right! (angle)
|
|
||||||
twisty_triangles! (dec (times), sub (radius, growth), angle, growth)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
& right! (inv (6))
|
|
||||||
& twisty_triangles! (8, 100, inv (120), 10)
|
|
||||||
|
|
||||||
& hideturtle! ()
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const result = run(code)
|
const result = run(code)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.38",
|
"version": "0.1.37",
|
||||||
"description": "A Ludus interpreter in a pure JS function.",
|
"description": "A Ludus interpreter in a pure JS function.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "build/ludus.mjs",
|
"main": "build/ludus.mjs",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user