Improved controls

This commit is contained in:
neauoire 2020-03-25 19:30:33 +09:00
parent 2387542efc
commit 12bba32b5d
4 changed files with 93 additions and 41 deletions

View File

@ -0,0 +1,82 @@
(clear)
;
(open $path)
; picker to elementary
(def unit 40)
(def f
(get-frame))
(def pos-row-1
(sub f:h
(mul unit 4)))
(def pos-row-2
(sub f:h
(mul unit 2)))
; color picker
(def color-1
(pick
(guide
(rect $xy unit unit))))
(def color-2
(pick
(guide
(rect $xy unit unit))))
(def color-3
(pick
(guide
(rect $xy unit unit))))
(def color-4
(pick
(guide
(rect $xy unit unit))))
(def color-5
(pick
(guide
(rect $xy unit unit))))
(def color-6
(pick
(guide
(rect $xy unit unit))))
(def color-7
(pick
(guide
(rect $xy unit unit))))
(def color-8
(pick
(guide
(rect $xy unit unit))))
; display
(fill
(circle
(mul unit 2) pos-row-1 unit) color-1)
(fill
(circle
(mul unit 4) pos-row-1 unit) color-2)
(fill
(circle
(mul unit 6) pos-row-1 unit) color-3)
(fill
(circle
(mul unit 8) pos-row-1 unit) color-4)
(fill
(circle
(mul unit 3) pos-row-2 unit) color-5)
(fill
(circle
(mul unit 5) pos-row-2 unit) color-6)
(fill
(circle
(mul unit 7) pos-row-2 unit) color-7)
(fill
(circle
(mul unit 9) pos-row-2 unit) color-8)
;
(def res
(add color-1:hex ":" color-2:hex ":" color-3:hex ":" color-4:hex ":" color-5:hex ":" color-6:hex ":" color-7:hex ":" color-8:hex))
(echo
(add res res))

View File

@ -539,7 +539,7 @@ function Client () {
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new(); this.surface.clear(); this.commander.clear() })
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.write('ronin', 'lisp', this.commander._input.value, 'text/plain') })
this.acels.set('File', 'Export Image', 'CmdOrCtrl+E', () => { this.source.write('ronin', 'png', this.surface.el.toDataURL('image/png', 1.0), 'image/png') })
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('lisp', this.whenOpen) })
this.acels.set('File', 'Open', 'CmdOrCtrl+U', () => { this.source.open('lisp', this.whenOpen) })
this.acels.add('Edit', 'undo')
this.acels.add('Edit', 'redo')
this.acels.add('Edit', 'cut')
@ -1353,18 +1353,6 @@ function Library (client) {
[-1, 9, -1],
[-1, -1, -1]]
}
this.dir = (path = this.dirpath()) => { // Returns the content of a directory.
}
this.file = (path = this.filepath()) => { // Returns the content of a file.
}
this.dirpath = (path = this.filepath()) => { // Returns the path of a directory.
}
this.filepath = (path = client.source.path) => { // Returns the path of a file.
}
this.dirname = (path = this.filepath()) => { // Returns the name of a folder.
}
this.filename = (path = this.filepath()) => { // Returns the name of a file.
}
this.offset = (a, b) => { // Offsets pos a with pos b, returns a.
a.x += b.x
a.y += b.y
@ -1373,6 +1361,10 @@ function Library (client) {
this.distance = (a, b) => { // Get distance between positions.
return Math.sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)))
}
this.print = (value) => {
client.source.write('ronin-print', 'txt', value, 'text/plain')
return value
}
this.echo = (...args) => { // Print arguments to interface.
client.log(args)
return args

View File

@ -47,7 +47,7 @@ function Client () {
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new(); this.surface.clear(); this.commander.clear() })
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.write('ronin', 'lisp', this.commander._input.value, 'text/plain') })
this.acels.set('File', 'Export Image', 'CmdOrCtrl+E', () => { this.source.write('ronin', 'png', this.surface.el.toDataURL('image/png', 1.0), 'image/png') })
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('lisp', this.whenOpen) })
this.acels.set('File', 'Open', 'CmdOrCtrl+U', () => { this.source.open('lisp', this.whenOpen) })
this.acels.add('Edit', 'undo')
this.acels.add('Edit', 'redo')

View File

@ -5,7 +5,6 @@
function Library (client) {
// IO
this.open = async (name, scale = 1) => { // Import a graphic and scale canvas to fit.
const img = client.cache.get(name)
if (!img) { client.log('No data for ' + name); return }
@ -544,32 +543,6 @@ function Library (client) {
[-1, -1, -1]]
}
// File System
this.dir = (path = this.dirpath()) => { // Returns the content of a directory.
// return fs.existsSync(path) ? fs.readdirSync(path) : []
}
this.file = (path = this.filepath()) => { // Returns the content of a file.
// return fs.existsSync(path) ? fs.readFileSync(path, 'utf8') : ''
}
this.dirpath = (path = this.filepath()) => { // Returns the path of a directory.
// return require('path').dirname(path)
}
this.filepath = (path = client.source.path) => { // Returns the path of a file.
// return path
}
this.dirname = (path = this.filepath()) => { // Returns the name of a folder.
// return require('path').basename(require('path').dirname(path))
}
this.filename = (path = this.filepath()) => { // Returns the name of a file.
// return require('path').parse(path).name
}
this.offset = (a, b) => { // Offsets pos a with pos b, returns a.
a.x += b.x
a.y += b.y
@ -580,6 +553,11 @@ function Library (client) {
return Math.sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)))
}
this.print = (value) => {
client.source.write('ronin-print', 'txt', value, 'text/plain')
return value
}
this.echo = (...args) => { // Print arguments to interface.
client.log(args)
return args