diff --git a/README.md b/README.md index 9f9ad65..a44d8ad 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,6 @@ npm start ## Library -Additional functions can be found in the [includes](https://github.com/hundredrabbits/Ronin/tree/master/desktop/sources/lisp), you can also look at the [examples](https://github.com/hundredrabbits/Ronin/tree/master/examples) to see them in action. - - `(import path shape)` Imports a graphic file with format. - `(export path ~format ~quality)` Exports a graphic file with format. - `(open path)` Imports a graphic file and resizes the frame. diff --git a/desktop/sources/lisp/prelude.lisp b/desktop/sources/lisp/prelude.lisp deleted file mode 100644 index 7c428ba..0000000 --- a/desktop/sources/lisp/prelude.lisp +++ /dev/null @@ -1,33 +0,0 @@ -; -(echo "Loading prelude.lisp") -; frame-rect -(def frame-rect - (frame)) -; translate -(defn translate - (r p) - (clone r - (rect p:x p:y r:w r:h))) -; times -(defn times - (v f) - ( - (f v) - (if - (gt v 1) - (times - (sub v 1) f)))) -; convert deg to radians -(defn deg-rad - (deg) - (mul deg - (div PI 180))) -; position on a circle from angle -(defn circle-pos - (cx cy r a) {:x - (add cx - (mul r - (cos a))) :y - (add cy - (mul r - (sin a)))}) \ No newline at end of file diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 1673723..2ebc3a8 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -213,15 +213,15 @@ function Commander (ronin) { // Splash - this.splash = `; welcome to ronin - v2.2 + this.splash = `; welcome to ronin - v2.21 (clear) -(def align { :x - (sub frame-rect:c 150) :y - (sub frame-rect:m 150)}) -; outline +(def frame-rect + (frame)) +(def align { + :x (sub (div frame-rect:c 2) 150) + :y (sub frame-rect:m 150)}) (fill (svg align:x align:y "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff") -; stroke (stroke (svg align:x align:y "M60,60 L195,60 A45,45 0 0,1 240,105 A45,45 0 0,1 195,150 L60,150 M195,150 A45,45 0 0,1 240,195 L240,240 ") 5 "#000")` diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 91dd30b..88fc713 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -162,7 +162,6 @@ function Library (ronin) { this.guide({ a: { x: rect.x, y: rect.y }, b: { x: pos.x + rect.x, y: pos.y + rect.y } }) this.guide(rect) this.guide(this.offset(rect, { x: pos.x, y: pos.y })) - ronin.surface.context.drawImage(crop, rect.x, rect.y) } diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index 07d2c91..7d7b959 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -1,6 +1,6 @@ 'use strict' -function Lisp (lib = {}, includes = []) { +function Lisp (lib = {}) { const path = require('path') const fs = require('fs') @@ -178,21 +178,12 @@ function Lisp (lib = {}, includes = []) { .map(function (x) { return x.replace(/!whitespace!/g, ' ') }) } - this.inc = function () { - return includes.reduce((acc, item) => { - const p = path.join(__dirname, `lisp/${item}.lisp`) - if (!fs.existsSync(p)) { console.warn('Lisp', `Missing include: ${p}`); return acc } - return `${acc}(include "${p}") ` - }, '') - } - this.parse = function (input) { return parenthesize(tokenize(input)) } this.run = async function (input) { return interpret(this.parse(`( - ${this.inc()} ${input})`)) } } diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 7b35c56..082a88c 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -11,8 +11,6 @@ function Ronin () { b_inv: '#ffb545' } - this.includes = ['prelude'] - this.el = document.createElement('div') this.el.id = 'ronin' @@ -21,7 +19,7 @@ function Ronin () { this.commander = new Commander(this) this.surface = new Surface(this) this.library = new Library(this) - this.interpreter = new Lisp(this.library, this.includes) + this.interpreter = new Lisp(this.library) this.osc = new Osc(this) this.bindings = {} diff --git a/examples/demo/stars.lisp b/examples/demo/stars.lisp index a3243b7..b93e657 100644 --- a/examples/demo/stars.lisp +++ b/examples/demo/stars.lisp @@ -1,6 +1,29 @@ ; stars (clear) -; +; times +(defn times + (v f) + ( + (f v) + (if + (gt v 1) + (times + (sub v 1) f)))) +; convert deg to radians +(defn deg-rad + (deg) + (mul deg + (div PI 180))) +; position on a circle from angle +(defn circle-pos + (cx cy r a) {:x + (add cx + (mul r + (cos a))) :y + (add cy + (mul r + (sin a)))}) +; draw (defn draw-spoke (cx cy r a) (