Added option to toggle guides, fixes #99

This commit is contained in:
Devine Lu Linvega
2019-08-03 08:29:43 +09:00
parent d6317b62fe
commit 40cdd11c1e
5 changed files with 18 additions and 14 deletions

View File

@@ -75,7 +75,7 @@ function Library (ronin) {
}
this.hsl = (h, s, l, a = 1) => { // returns a HSL color object
return { h, s, l, a, toString: () => { return `hsla(${h},${s}%,${l}%,${a})` }, 0: h, 1: s, 2: l, 3: a, f: [h / 360, s / 100, l / 100, a] }
return { h, s, l, a, toString: () => { return `hsla(${h},${s}%,${l}%,${a})` }, 0: h, 1: s, 2: l, 3: a, f: [h / 360, s / 100, l / 100, a] }
}
// Frame
@@ -149,9 +149,13 @@ function Library (ronin) {
// Transforms
this.transform = {
push: () => { ronin.surface.context.save() },
pop: () => { ronin.surface.context.restore() },
this.transform = { // The transform toolkit, use like (transform:move 10 10).
push: () => {
ronin.surface.context.save()
},
pop: () => {
ronin.surface.context.restore()
},
reset: () => {
ronin.surface.context.resetTransform()
ronin.surface.guide.resetTransform()

View File

@@ -304,6 +304,10 @@ function Surface (ronin) {
})
}
this.toggleGuides = function () {
this._guide.className = this._guide.className === 'hidden' ? '' : 'hidden'
}
function isRect (shape) {
return shape && !isNaN(shape.x) && !isNaN(shape.y) && !isNaN(shape.w) && !isNaN(shape.h)
}