summaryrefslogtreecommitdiff
path: root/js/ui/transform.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ui/transform.js')
-rw-r--r--js/ui/transform.js38
1 files changed, 25 insertions, 13 deletions
diff --git a/js/ui/transform.js b/js/ui/transform.js
index b0ef894..b155af5 100644
--- a/js/ui/transform.js
+++ b/js/ui/transform.js
@@ -60,25 +60,32 @@ var transform = (function(){
},
},
-/*
scale: {
init: function(e){
+ mode.independent = e.shiftKey || e.altKey || e.metaKey
+ mode.x_scale = mode.y_scale = 0
},
- before: function(dx, dy){
+ before: function(dx, dy, pdx, pdy){
+ if (mode.independent) {
+ mode.x_scale = Math.pow(2, -pdx / (canvas.w / 8))
+ mode.y_scale = Math.pow(2, -pdy / (canvas.h / 8))
+ }
+ else {
+ mode.x_scale = mode.y_scale = Math.pow(2, -pdx / (canvas.w / 8))
+ }
},
shade: function(src, dest, lex, x, y, w, h){
- x = (x/w) * 2 - 1
- y = (y/h) * 2 - 1
- x *= this.x_scale
- y *= this.y_scale
+ x = ((x-p[0])/w) * 2 - 1
+ y = ((y-p[1])/h) * 2 - 1
+ x *= mode.x_scale
+ y *= mode.y_scale
x = (x + 1) / 2 * w
y = (y + 1) / 2 * h
- var copy = src.get(x, y)
+ var copy = src.get(x+p[0], y+p[1])
lex.assign(copy)
return true
},
},
-*/
translate: {
init: function(e){
@@ -98,11 +105,16 @@ var transform = (function(){
slice: {
init: function(e){
mode.position = 0
+ mode.is_y = e.shiftKey || e.altKey || e.metaKey
},
- before: function(dx, dy){
- var dd = mode.is_y ? dy : dx
- mode.position = mod(mode.position + dd, mode.limit)
- mode.direction = dy
+ before: function(dx, dy, pdx, pdy){
+ var pd = mode.is_y ? pdy : pdx
+ var dd = mode.is_y ? pdx : pdy
+ var new_position = mod(mode.position + pd, mode.limit)
+ if (mode.position !== new_position) {
+ mode.position = new_position
+ }
+ mode.direction = dd
copy.assign(canvas)
},
shade: function(src, dest, lex, x, y, w, h){
@@ -124,7 +136,7 @@ var transform = (function(){
mode: {
init: function(e){
},
- before: function(dx, dy){
+ before: function(dx, dy, pdx, pdy){
},
shade: function(src, dest, lex, x, y, w, h){
},