Added the circle shape
This commit is contained in:
parent
c99ae1dad7
commit
685d70439b
@ -16,23 +16,17 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
|
||||
const {dialog,app} = require('electron').remote;
|
||||
const fs = require('fs');
|
||||
|
||||
const app_path = app.getAppPath();
|
||||
|
||||
var ronin = new Ronin();
|
||||
|
||||
const ronin = new Ronin();
|
||||
ronin.controller = new Controller();
|
||||
|
||||
ronin.controller.add("default","*","About",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Dotgrid'); },"CmdOrCtrl+,");
|
||||
ronin.controller.add("default","*","Fullscreen",() => { app.toggleFullscreen(); },"CmdOrCtrl+Enter");
|
||||
ronin.controller.add("default","*","Hide",() => { app.toggleVisible(); },"CmdOrCtrl+H");
|
||||
ronin.controller.add("default","*","Inspect",() => { app.inspect(); },"CmdOrCtrl+.");
|
||||
ronin.controller.add("default","*","Reset",() => { dotgrid.reset(); dotgrid.theme.reset(); },"CmdOrCtrl+Backspace");
|
||||
ronin.controller.add("default","*","Quit",() => { app.exit(); },"CmdOrCtrl+Q");
|
||||
|
||||
ronin.controller.addRole('default', 'Edit', 'undo')
|
||||
ronin.controller.addRole('default', 'Edit', 'redo')
|
||||
ronin.controller.addRole('default', 'Edit', 'cut')
|
||||
@ -40,14 +34,10 @@
|
||||
ronin.controller.addRole('default', 'Edit', 'paste')
|
||||
ronin.controller.addRole('default', 'Edit', 'delete')
|
||||
ronin.controller.addRole('default', 'Edit', 'selectall')
|
||||
|
||||
ronin.controller.add("default","Project","Run",() => { ronin.commander.run(); },"CmdOrCtrl+R");
|
||||
ronin.controller.add("default","Commander","Toggle",() => { ronin.commander.toggle(); },"CmdOrCtrl+K");
|
||||
|
||||
ronin.controller.commit();
|
||||
|
||||
ronin.install(document.body);
|
||||
|
||||
window.addEventListener('load', () => { ronin.start(); })
|
||||
</script>
|
||||
</body>
|
||||
|
@ -78,7 +78,7 @@ function Library (ronin) {
|
||||
return arr
|
||||
}
|
||||
|
||||
// Rects
|
||||
// Shapes
|
||||
|
||||
this.pos = (x, y, t = 'pos') => {
|
||||
return { x, y }
|
||||
@ -92,6 +92,10 @@ function Library (ronin) {
|
||||
return { x, y, w, h, t }
|
||||
}
|
||||
|
||||
this.circle = (x, y, r, t = 'circle') => {
|
||||
return { x, y, r, t }
|
||||
}
|
||||
|
||||
this.line = (a, b, t = 'line') => {
|
||||
return { a, b, t }
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ function Surface (ronin) {
|
||||
this.strokeRect(shape, width, color)
|
||||
} else if (shape.t === 'line') {
|
||||
this.strokeLine(shape, width, color)
|
||||
} else if (shape.t === 'circle') {
|
||||
this.strokeCircle(shape, width, color)
|
||||
} else {
|
||||
console.warn('Unknown type')
|
||||
}
|
||||
@ -57,11 +59,22 @@ function Surface (ronin) {
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
this.strokeCircle = function (circle, width, color) {
|
||||
this.context.beginPath()
|
||||
this.context.arc(circle.x, circle.y, circle.r, 0, 2 * Math.PI)
|
||||
this.context.lineWidth = width
|
||||
this.context.strokeStyle = color
|
||||
this.context.stroke()
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
// Fill
|
||||
|
||||
this.fill = (shape, color) => {
|
||||
if (shape.t === 'rect') {
|
||||
this.fillRect(shape, color)
|
||||
} else if (shape.t === 'circle') {
|
||||
this.fillCircle(shape, color)
|
||||
} else {
|
||||
console.warn('Unknown type')
|
||||
}
|
||||
@ -79,6 +92,14 @@ function Surface (ronin) {
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
this.fillCircle = function (circle, color) {
|
||||
this.context.beginPath()
|
||||
this.context.arc(circle.x, circle.y, circle.r, 0, 2 * Math.PI)
|
||||
this.context.fillStyle = color
|
||||
this.context.fill()
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
// IO
|
||||
|
||||
this.open = function (path, scale) {
|
||||
|
4
examples/shapes.lisp
Normal file
4
examples/shapes.lisp
Normal file
@ -0,0 +1,4 @@
|
||||
; Shapes
|
||||
|
||||
(
|
||||
(fill (circle (div (of (frame) "w") 2) (div (of (frame) "h") 2) 100) "red"))
|
Loading…
x
Reference in New Issue
Block a user