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 turtle = svg_render_turtle(states[states.length - 1])
|
||||
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" />
|
||||
|
||||
|
|
|
@ -1,66 +1,33 @@
|
|||
import {run, svg, stdout} from "./ludus.mjs"
|
||||
|
||||
const code = `
|
||||
background! (colors :white)
|
||||
pencolor! (colors :maroon)
|
||||
penwidth!(7)
|
||||
pencolor!(:red)
|
||||
background!(:maroon)
|
||||
|
||||
fn ngon! (n, edge) -> {
|
||||
repeat n {
|
||||
forward! (edge)
|
||||
right! (inv (n))
|
||||
fn ngon! (num_sides, side_len) -> {
|
||||
repeat num_sides {
|
||||
forward! (side_len)
|
||||
right! (inv (num_sides))
|
||||
}
|
||||
}
|
||||
|
||||
fn cngon! (n, radius) -> {
|
||||
let angle = add (inv (4), inv (mult (2, n)))
|
||||
let edge = mult (2, radius, sin (inv (mult (2, n))))
|
||||
|
||||
penup! ()
|
||||
forward! (radius)
|
||||
right! (angle)
|
||||
pendown! ()
|
||||
ngon! (n, edge)
|
||||
left! (angle)
|
||||
penup! ()
|
||||
back! (radius)
|
||||
pendown! ()
|
||||
fn show_gons! (n, side_len) -> {
|
||||
if lte? (n, 0)
|
||||
then :ok
|
||||
else {
|
||||
ngon! (n, side_len)
|
||||
penup!()
|
||||
rt!(0.01)
|
||||
fd!(add (side_len, 10))
|
||||
pendown!()
|
||||
show_gons! (sub (n, 1), side_len)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
show_gons! (100, 100)
|
||||
|
||||
twisty_nonagons! (10, 0, 100, 3)
|
||||
|
||||
fn centre_squares! (times, radius, growth) -> {
|
||||
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! ()
|
||||
hideturtle!()
|
||||
`
|
||||
|
||||
const result = run(code)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ludus/ludus-js-pure",
|
||||
"version": "0.1.38",
|
||||
"version": "0.1.37",
|
||||
"description": "A Ludus interpreter in a pure JS function.",
|
||||
"type": "module",
|
||||
"main": "build/ludus.mjs",
|
||||
|
|
Loading…
Reference in New Issue
Block a user