Skip to content

Commit

Permalink
Re-implemented (export)
Browse files Browse the repository at this point in the history
  • Loading branch information
neauoire committed Nov 2, 2019
1 parent 707f056 commit ff934f9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 54 deletions.
15 changes: 15 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
permalink: /404.html
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loading..</title>
</head>
<body style='background:black'>
<script>
document.location.href = '/index.html'
</script>
</body>
</html>
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i

## Library

- `(import path shape ~alpha)` Imports a graphic file with format.
- `(export path ~format ~quality)` Exports a graphic file with format.
- `(open path ~ratio)` Imports a graphic file and resizes the frame.
- `(exit ~force)` Exits Ronin.
- `(export ~name ~format ~quality)` Exports a graphic file with format.
- `(pos ~x ~y)` Returns a position shape.
- `(line ax ay bx by)` Returns a line shape.
- `(size w h)` Returns a size shape.
Expand Down Expand Up @@ -126,12 +123,6 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
- `(blur)` Returns the blur kernel.
- `(sharpen)` Returns the sharpen kernel.
- `(edge)` Returns the edge kernel.
- `(dir ~path)` Returns the content of a directory.
- `(file ~path)` Returns the content of a file.
- `(dirpath ~path)` Returns the path of a directory.
- `(filepath ~path)` Returns the path of a file.
- `(dirname ~path)` Returns the name of a folder.
- `(filename ~path)` Returns the name of a file.
- `(offset a b)` Offsets pos a with pos b, returns a.
- `(distance a b)` Get distance between positions.
- `(echo ...args)` Print arguments to interface.
Expand All @@ -142,6 +133,19 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
- `(test name a b)`
- `(benchmark fn)` Logs time taken to execute a function.

### In Development

- `(import path shape ~alpha)` Imports a graphic file with format.
- `(export path ~format ~quality)` Exports a graphic file with format.
- `(open path ~ratio)` Imports a graphic file and resizes the frame.
- `(exit ~force)` Exits Ronin.
- `(dir ~path)` Returns the content of a directory.
- `(file ~path)` Returns the content of a file.
- `(dirpath ~path)` Returns the path of a directory.
- `(filepath ~path)` Returns the path of a file.
- `(dirname ~path)` Returns the name of a folder.
- `(filename ~path)` Returns the name of a file.

<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW2.jpg' width='600'/>

<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW3.jpg' width='600'/>
Expand Down
18 changes: 9 additions & 9 deletions desktop/sources/scripts/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ function Library (ronin) {
// IO

this.import = async (path, shape, alpha = 1) => { // Imports a graphic file with format.
const img = new Image()
img.src = path
return ronin.surface.draw(img, shape, alpha)
// const img = new Image()
// img.src = path
// return ronin.surface.draw(img, shape, alpha)
}

this.export = (path, quality = 1.0) => { // Exports a graphic file with format.
// if (!path) { console.warn('Missing export path'); return path }
// const dataUrl = ronin.surface.el.toDataURL(path.indexOf('.jpg') > -1 ? 'image/jpeg' : path.indexOf('.png') > -1 ? 'image/png' : format, quality)
// const data = dataUrl.replace(/^data:image\/png;base64,/, '').replace(/^data:image\/jpeg;base64,/, '')
// fs.writeFileSync(path, data, 'base64')
// return path
this.export = (name = 'export', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
const base64 = ronin.surface.el.toDataURL(type, quality)
const link = document.createElement('a')
link.setAttribute('href', base64)
link.setAttribute('download', type === 'image/png' ? name + '.png' : name + '.jpg')
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
}

this.open = async (path, ratio = 1) => { // Imports a graphic file and resizes the frame.
Expand Down
6 changes: 1 addition & 5 deletions desktop/sources/scripts/ronin.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ function Ronin () {
requestAnimationFrame(() => this.loop())
}

this.reset = function () {
this.theme.reset()
}

this.log = function (...msg) {
this.log = (...msg) => {
this.commander.setStatus(msg.reduce((acc, val) => {
return acc + JSON.stringify(val).replace(/"/g, '').trim() + ' '
}, ''))
Expand Down
9 changes: 5 additions & 4 deletions desktop/sources/scripts/surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,11 @@ function Surface (ronin) {
}

this.fitWindow = function (size) {
const win = require('electron').remote.getCurrentWindow()
const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 }
if (size.w < 10 || size.h < 10) { return }
win.setSize(Math.floor((size.w / this.ratio) + pad.w), Math.floor((size.h / this.ratio) + pad.h), true)
console.log('TODO')
// const win = require('electron').remote.getCurrentWindow()
// const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 }
// if (size.w < 10 || size.h < 10) { return }
// win.setSize(Math.floor((size.w / this.ratio) + pad.w), Math.floor((size.h / this.ratio) + pad.h), true)
}

this.maximize = () => {
Expand Down
11 changes: 1 addition & 10 deletions examples/basics/benchmark.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,4 @@

; Interop
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
(test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)

; fs

; filesystem

(echo (filepath))
(echo (dirpath))
(echo (file))
(echo (dir))
(test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)
16 changes: 0 additions & 16 deletions examples/basics/recursive.lisp

This file was deleted.

0 comments on commit ff934f9

Please sign in to comment.