Improve splash alignment
This commit is contained in:
parent
b844cbbc17
commit
94b062005a
@ -33,8 +33,6 @@ npm start
|
|||||||
|
|
||||||
## Library
|
## 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.
|
- `(import path shape)` Imports a graphic file with format.
|
||||||
- `(export path ~format ~quality)` Exports 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.
|
- `(open path)` Imports a graphic file and resizes the frame.
|
||||||
|
@ -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)))})
|
|
@ -213,15 +213,15 @@ function Commander (ronin) {
|
|||||||
|
|
||||||
// Splash
|
// Splash
|
||||||
|
|
||||||
this.splash = `; welcome to ronin - v2.2
|
this.splash = `; welcome to ronin - v2.21
|
||||||
(clear)
|
(clear)
|
||||||
(def align { :x
|
(def frame-rect
|
||||||
(sub frame-rect:c 150) :y
|
(frame))
|
||||||
(sub frame-rect:m 150)})
|
(def align {
|
||||||
; outline
|
:x (sub (div frame-rect:c 2) 150)
|
||||||
|
:y (sub frame-rect:m 150)})
|
||||||
(fill
|
(fill
|
||||||
(svg align:x align:y "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff")
|
(svg align:x align:y "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff")
|
||||||
; stroke
|
|
||||||
(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")`
|
(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")`
|
||||||
|
|
||||||
|
@ -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({ a: { x: rect.x, y: rect.y }, b: { x: pos.x + rect.x, y: pos.y + rect.y } })
|
||||||
this.guide(rect)
|
this.guide(rect)
|
||||||
this.guide(this.offset(rect, { x: pos.x, y: pos.y }))
|
this.guide(this.offset(rect, { x: pos.x, y: pos.y }))
|
||||||
|
|
||||||
ronin.surface.context.drawImage(crop, rect.x, rect.y)
|
ronin.surface.context.drawImage(crop, rect.x, rect.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
function Lisp (lib = {}, includes = []) {
|
function Lisp (lib = {}) {
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
@ -178,21 +178,12 @@ function Lisp (lib = {}, includes = []) {
|
|||||||
.map(function (x) { return x.replace(/!whitespace!/g, ' ') })
|
.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) {
|
this.parse = function (input) {
|
||||||
return parenthesize(tokenize(input))
|
return parenthesize(tokenize(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
this.run = async function (input) {
|
this.run = async function (input) {
|
||||||
return interpret(this.parse(`(
|
return interpret(this.parse(`(
|
||||||
${this.inc()}
|
|
||||||
${input})`))
|
${input})`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ function Ronin () {
|
|||||||
b_inv: '#ffb545'
|
b_inv: '#ffb545'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.includes = ['prelude']
|
|
||||||
|
|
||||||
this.el = document.createElement('div')
|
this.el = document.createElement('div')
|
||||||
this.el.id = 'ronin'
|
this.el.id = 'ronin'
|
||||||
|
|
||||||
@ -21,7 +19,7 @@ function Ronin () {
|
|||||||
this.commander = new Commander(this)
|
this.commander = new Commander(this)
|
||||||
this.surface = new Surface(this)
|
this.surface = new Surface(this)
|
||||||
this.library = new Library(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.osc = new Osc(this)
|
||||||
|
|
||||||
this.bindings = {}
|
this.bindings = {}
|
||||||
|
@ -1,6 +1,29 @@
|
|||||||
; stars
|
; stars
|
||||||
(clear)
|
(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
|
(defn draw-spoke
|
||||||
(cx cy r a)
|
(cx cy r a)
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user