add prelude.lisp

This commit is contained in:
Quentin Leonetti 2019-07-20 21:25:28 +02:00
parent fade8cb396
commit 0f2acc0d0e
3 changed files with 20 additions and 8 deletions

View File

@ -0,0 +1,11 @@
(echo "Loading prelude.lisp")
(defn translate
(r p)
(clone
r
(rect
(of p :x)
(of p :y)
(of r :w)
(of r :h))))

View File

@ -167,10 +167,12 @@ function Lisp (input, lib) {
} }
this.parse = function (input) { this.parse = function (input) {
return parenthesize(tokenize(`(${input})`)) return parenthesize(tokenize(input))
} }
this.toPixels = async function () { this.toPixels = async function () {
return interpret(this.parse(input)) return interpret(this.parse(`(
(include "./sources/lisp/prelude.lisp")
${input})`))
} }
} }

View File

@ -5,12 +5,11 @@
(defn glitch (defn glitch
(rec) (rec)
(if (gt rec 1) (if (gt rec 1)
((clone (
(rect (random 400) (random 400) 2 2) (translate
(rect (random 400) (random 400) (rect (random 400) (random 400) (random 10) (random 10))
(random 10) (random 30))) (pos (random 400) (random 400)))
(glitch (sub rec 1)))) (glitch (sub rec 1)))))
)
(import (import
"../static/crystal.jpg" "../static/crystal.jpg"