*
This commit is contained in:
parent
3e9cb56089
commit
1e245e144e
@ -85,9 +85,10 @@ npm start
|
|||||||
- `(echo ...args)`
|
- `(echo ...args)`
|
||||||
- `(str ...args)`
|
- `(str ...args)`
|
||||||
- `(open path)` Imports a graphic file and resizes the frame.
|
- `(open path)` Imports a graphic file and resizes the frame.
|
||||||
- `(path ~path)` Returns the content of a folder path.
|
- `(dir ~path)` Returns the content of a directory.
|
||||||
- `(folder ~path)` Returns the path of the current folder.
|
- `(file ~path)` Returns the content of a file
|
||||||
- `(ls ~path)` Returns the content of a folder path.
|
- `(dirpath ~path)` Returns the path of a directory.
|
||||||
|
- `(filepath ~path)` Returns the path of a file
|
||||||
- `(exit ~force)` Exits Ronin.
|
- `(exit ~force)` Exits Ronin.
|
||||||
- `(time)` Returns timestamp in milliseconds.
|
- `(time)` Returns timestamp in milliseconds.
|
||||||
- `(animate ~play)` Toggles animation.
|
- `(animate ~play)` Toggles animation.
|
||||||
|
@ -327,15 +327,19 @@ function Library (ronin) {
|
|||||||
|
|
||||||
// File System
|
// File System
|
||||||
|
|
||||||
this.path = (path = ronin.source.path) => { // Returns the content of a folder path.
|
this.dir = (path = ronin.source.path) => { // Returns the content of a directory.
|
||||||
return path
|
return fs.existsSync(path) ? fs.readdirSync(path) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
this.folder = (path = this.path()) => { // Returns the path of the current folder.
|
this.file = (path = ronin.source.path) => { // Returns the content of a file
|
||||||
|
return fs.existsSync(path) ? fs.readFileSync(p, 'utf8') : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dirpath = (path = ronin.source.path) => { // Returns the path of a directory.
|
||||||
return require('path').dirname(path)
|
return require('path').dirname(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ls = (path = this.folder()) => { // Returns the content of a folder path.
|
this.filepath = (path = ronin.source.path) => { // Returns the path of a file
|
||||||
return fs.existsSync(path) ? fs.readdirSync(path) : []
|
return fs.existsSync(path) ? fs.readdirSync(path) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
159
documentation.md
159
documentation.md
@ -1,159 +0,0 @@
|
|||||||
# Functions
|
|
||||||
|
|
||||||
## IO
|
|
||||||
|
|
||||||
`(open path)`
|
|
||||||
|
|
||||||
`(export path type quality)`
|
|
||||||
|
|
||||||
`(draw path rect)`
|
|
||||||
|
|
||||||
`(resize width height)`
|
|
||||||
|
|
||||||
`(crop rect)`
|
|
||||||
|
|
||||||
`(folder path)`
|
|
||||||
|
|
||||||
`(exit)`
|
|
||||||
|
|
||||||
## Logic
|
|
||||||
|
|
||||||
`(gt a b)` check if `a` is greater than `b`
|
|
||||||
|
|
||||||
`(lt a b)` check if `a` is lower than `b`
|
|
||||||
|
|
||||||
`(eq a b)` check if `a` is equal to `b`
|
|
||||||
|
|
||||||
`(and a b <c d...>)` returns true if all conditions are true
|
|
||||||
|
|
||||||
`(or a b <cd...>)` returns true if at least one condition is true
|
|
||||||
|
|
||||||
## Arrays
|
|
||||||
|
|
||||||
`(map function array)`
|
|
||||||
|
|
||||||
`(filter function array)`
|
|
||||||
|
|
||||||
`(reduce function array accumulator)`
|
|
||||||
|
|
||||||
`(len array)`
|
|
||||||
|
|
||||||
`(first array)`
|
|
||||||
|
|
||||||
`(last array)`
|
|
||||||
|
|
||||||
`(rest array)`
|
|
||||||
|
|
||||||
`(range start end step)`
|
|
||||||
|
|
||||||
## Shapes
|
|
||||||
|
|
||||||
`(pos x y)`
|
|
||||||
|
|
||||||
`(size w h)`
|
|
||||||
|
|
||||||
`(rect x y w h t)`
|
|
||||||
|
|
||||||
`(circle x y r)`
|
|
||||||
|
|
||||||
`(line start end)`
|
|
||||||
|
|
||||||
`(text x y g string font)`
|
|
||||||
|
|
||||||
`(svg data)`
|
|
||||||
|
|
||||||
## Helpers
|
|
||||||
|
|
||||||
`(frame)`
|
|
||||||
|
|
||||||
`(center)`
|
|
||||||
|
|
||||||
`(scale rect width height)`
|
|
||||||
|
|
||||||
## Copy/Paste
|
|
||||||
|
|
||||||
`(clone start end)` clone start `rect` into end `rect`
|
|
||||||
|
|
||||||
`(stroke shape thickness color)`
|
|
||||||
|
|
||||||
`(fill shape color)`
|
|
||||||
|
|
||||||
`(clear shape)`
|
|
||||||
|
|
||||||
## Objects
|
|
||||||
|
|
||||||
`(get item key <keys>)`
|
|
||||||
|
|
||||||
`(set item key val)`
|
|
||||||
|
|
||||||
## Colors
|
|
||||||
|
|
||||||
`(theme variable)`
|
|
||||||
|
|
||||||
`(gradient (x1,y1,x2,y2) colors)`
|
|
||||||
|
|
||||||
`(pixels rect function q)`
|
|
||||||
|
|
||||||
`(saturation pixel q)`
|
|
||||||
|
|
||||||
`(contrast pixel q)`
|
|
||||||
|
|
||||||
## Math
|
|
||||||
|
|
||||||
`(add ...values)`
|
|
||||||
|
|
||||||
`(sub...values)`
|
|
||||||
|
|
||||||
`(mul ...values)`
|
|
||||||
|
|
||||||
`(div ...values)`
|
|
||||||
|
|
||||||
`(mod a b)`
|
|
||||||
|
|
||||||
`(clamp value min max)`
|
|
||||||
|
|
||||||
`(step value step)`
|
|
||||||
|
|
||||||
`(min a b)`
|
|
||||||
|
|
||||||
`(max a b)`
|
|
||||||
|
|
||||||
`(ceil value)`
|
|
||||||
|
|
||||||
`(floor value)`
|
|
||||||
|
|
||||||
`(sin a)`
|
|
||||||
|
|
||||||
`(cos a)`
|
|
||||||
|
|
||||||
`PI, TWO_PI`
|
|
||||||
|
|
||||||
`(random)`
|
|
||||||
|
|
||||||
`(random start end)`
|
|
||||||
|
|
||||||
`(random max)`
|
|
||||||
|
|
||||||
## Generics
|
|
||||||
|
|
||||||
`(echo args)`
|
|
||||||
|
|
||||||
`(str args)`
|
|
||||||
|
|
||||||
`(test name value expectedValue)`
|
|
||||||
|
|
||||||
## Livecoding
|
|
||||||
|
|
||||||
`(time)` returns timestamp in milliseconds
|
|
||||||
|
|
||||||
`(animate)` start animation
|
|
||||||
|
|
||||||
`(animate false)` stop animation
|
|
||||||
|
|
||||||
## Javascript interop
|
|
||||||
|
|
||||||
`js`
|
|
||||||
|
|
||||||
## Client
|
|
||||||
|
|
||||||
`ronin`
|
|
@ -2,8 +2,8 @@
|
|||||||
(
|
(
|
||||||
; get files
|
; get files
|
||||||
(def files
|
(def files
|
||||||
(ls
|
(dir
|
||||||
(folder)))
|
(dirpath)))
|
||||||
; pick a random file
|
; pick a random file
|
||||||
(def random-index
|
(def random-index
|
||||||
(floor
|
(floor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user