Added files fn
This commit is contained in:
parent
660180d6b8
commit
da839efa8f
@ -62,6 +62,7 @@ Library
|
|||||||
- (open name ~scale) Imports a graphic file with format.
|
- (open name ~scale) Imports a graphic file with format.
|
||||||
- (import name ~shape) Imports a graphic file with format.
|
- (import name ~shape) Imports a graphic file with format.
|
||||||
- (export ~format ~quality) Exports a graphic file with format.
|
- (export ~format ~quality) Exports a graphic file with format.
|
||||||
|
- (files) Returns the list of loaded files.
|
||||||
- (print string) Exports string to file.
|
- (print string) Exports string to file.
|
||||||
- (pos ~x ~y) Returns a position shape.
|
- (pos ~x ~y) Returns a position shape.
|
||||||
- (line ax ay bx by) Returns a line shape.
|
- (line ax ay bx by) Returns a line shape.
|
||||||
|
25
index.html
25
index.html
@ -593,15 +593,7 @@ function Client () {
|
|||||||
this.onMouseOut = (e) => {
|
this.onMouseOut = (e) => {
|
||||||
this.mouseOrigin = null
|
this.mouseOrigin = null
|
||||||
}
|
}
|
||||||
this.onDrag = (e) => {
|
this.parseFile = (file) => {
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
e.dataTransfer.dropEffect = 'copy'
|
|
||||||
}
|
|
||||||
this.onDrop = (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
e.stopPropagation()
|
|
||||||
const file = e.dataTransfer.files[0]
|
|
||||||
if (file.name.indexOf('.lisp') > -1) {
|
if (file.name.indexOf('.lisp') > -1) {
|
||||||
this.source.read(file, this.whenOpen)
|
this.source.read(file, this.whenOpen)
|
||||||
this.log('Loaded ' + file.name)
|
this.log('Loaded ' + file.name)
|
||||||
@ -617,6 +609,18 @@ function Client () {
|
|||||||
console.warn('Unknown format', file)
|
console.warn('Unknown format', file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.onDrag = (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
e.dataTransfer.dropEffect = 'copy'
|
||||||
|
}
|
||||||
|
this.onDrop = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
for (const file of e.dataTransfer.files) {
|
||||||
|
this.parseFile(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
this.cache = {
|
this.cache = {
|
||||||
data: {},
|
data: {},
|
||||||
set: (key, content) => {
|
set: (key, content) => {
|
||||||
@ -900,6 +904,9 @@ function Library (client) {
|
|||||||
const type = `image/${format === 'jpeg' || format === 'jpg' ? 'jpeg' : 'png'}`
|
const type = `image/${format === 'jpeg' || format === 'jpg' ? 'jpeg' : 'png'}`
|
||||||
client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type)
|
client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type)
|
||||||
}
|
}
|
||||||
|
this.files = () => {
|
||||||
|
return Object.keys(client.cache.data)
|
||||||
|
}
|
||||||
this.pos = (x = 0, y = 0) => { // Returns a position shape.
|
this.pos = (x = 0, y = 0) => { // Returns a position shape.
|
||||||
return { x, y }
|
return { x, y }
|
||||||
}
|
}
|
||||||
|
@ -158,17 +158,7 @@ function Client () {
|
|||||||
this.mouseOrigin = null
|
this.mouseOrigin = null
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onDrag = (e) => {
|
this.parseFile = (file) => {
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
e.dataTransfer.dropEffect = 'copy'
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onDrop = (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
e.stopPropagation()
|
|
||||||
const file = e.dataTransfer.files[0]
|
|
||||||
|
|
||||||
if (file.name.indexOf('.lisp') > -1) {
|
if (file.name.indexOf('.lisp') > -1) {
|
||||||
this.source.read(file, this.whenOpen)
|
this.source.read(file, this.whenOpen)
|
||||||
this.log('Loaded ' + file.name)
|
this.log('Loaded ' + file.name)
|
||||||
@ -185,6 +175,20 @@ function Client () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.onDrag = (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
e.dataTransfer.dropEffect = 'copy'
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onDrop = (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
for (const file of e.dataTransfer.files) {
|
||||||
|
this.parseFile(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.cache = {
|
this.cache = {
|
||||||
data: {},
|
data: {},
|
||||||
set: (key, content) => {
|
set: (key, content) => {
|
||||||
|
@ -25,6 +25,10 @@ function Library (client) {
|
|||||||
client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type)
|
client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.files = () => {
|
||||||
|
return Object.keys(client.cache.data)
|
||||||
|
}
|
||||||
|
|
||||||
// Shapes
|
// Shapes
|
||||||
|
|
||||||
this.pos = (x = 0, y = 0) => { // Returns a position shape.
|
this.pos = (x = 0, y = 0) => { // Returns a position shape.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user