Added scale and echo
This commit is contained in:
parent
ef77a1b73d
commit
55b1e54fad
@ -9,11 +9,11 @@ function Library (ronin) {
|
||||
|
||||
// Rects
|
||||
|
||||
this.pos = (x, y) => {
|
||||
this.pos = (x, y, t = 'pos') => {
|
||||
return { x, y }
|
||||
}
|
||||
|
||||
this.size = (w, h) => {
|
||||
this.size = (w, h, t = 'size') => {
|
||||
return { w, h }
|
||||
}
|
||||
|
||||
@ -26,13 +26,17 @@ function Library (ronin) {
|
||||
}
|
||||
|
||||
this.frame = () => {
|
||||
return { x: 0, y: 0, w: Math.floor(window.innerWidth / 2) - 15, h: Math.floor(window.innerHeight) - 30 }
|
||||
return this.rect(0, 0, Math.floor(window.innerWidth / 2) - 15, Math.floor(window.innerHeight) - 30)
|
||||
}
|
||||
|
||||
this.path = (path) => {
|
||||
return path
|
||||
}
|
||||
|
||||
this.scale = (rect, w, h) => {
|
||||
return { x: rect.x, y: rect.y, w: rect.w * w, h: rect.h * h }
|
||||
}
|
||||
|
||||
// Copy/Paste
|
||||
|
||||
this.clone = (a, b) => {
|
||||
@ -54,4 +58,9 @@ function Library (ronin) {
|
||||
ronin.surface.clear(rect)
|
||||
return rect
|
||||
}
|
||||
|
||||
this.echo = function (any) {
|
||||
console.log(any)
|
||||
return any
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ function Surface (ronin) {
|
||||
this.ratio = window.devicePixelRatio
|
||||
this.context = this.el.getContext('2d')
|
||||
|
||||
this.guides = []
|
||||
|
||||
this.install = function (host) {
|
||||
host.appendChild(this.el)
|
||||
window.addEventListener('resize', (e) => { this.onResize() }, false)
|
||||
@ -21,9 +19,7 @@ function Surface (ronin) {
|
||||
}
|
||||
|
||||
this.update = function () {
|
||||
for (const id in this.guides) {
|
||||
// this.drawRect(this.guides[id])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Shape
|
||||
@ -97,11 +93,6 @@ function Surface (ronin) {
|
||||
this.context.drawImage(this.el, a.x, a.y, a.w, a.h, b.x, b.y, b.w, b.h)
|
||||
}
|
||||
|
||||
this.addGuide = function (rect) {
|
||||
this.guides.push(rect)
|
||||
this.update()
|
||||
}
|
||||
|
||||
this.resize = function (size) {
|
||||
this.el.width = size.w
|
||||
this.el.height = size.h
|
||||
|
3
examples/scale.lisp
Normal file
3
examples/scale.lisp
Normal file
@ -0,0 +1,3 @@
|
||||
; scale file
|
||||
|
||||
(echo (scale ($rect) 0.5 0.5))
|
Loading…
x
Reference in New Issue
Block a user