layer translate (change position)

This commit is contained in:
Vilius 2017-05-16 23:43:42 +03:00
parent ea3f02901e
commit 98e7ebdf90
2 changed files with 20 additions and 0 deletions

View File

@ -201,6 +201,7 @@
<li><a class="trn" onclick="call_menu(LAYER, 'layer_move_down');" href="#">Down</a></li>
</ul>
</li>
<li><a class="trn dots" onclick="call_menu(LAYER, 'layer_translate');" href="#">Translate </a></li>
<li><a class="trn dots" onclick="call_menu(LAYER, 'layer_opacity');" href="#">Opacity</a></li>
<li><a class="trn dots" onclick="call_menu(LAYER, 'layer_rename');" href="#">Rename</a></li>
<li><div class="mid-line"></div></li>

View File

@ -31,6 +31,25 @@ function LAYER_CLASS() {
this.layer_add();
};
//remaps layer at different position
this.layer_translate = function () {
POP.add({name: "x", title: "X position:", value: 0});
POP.add({name: "y", title: "Y position:", value: 0});
POP.show('Translate to', [LAYER, 'layer_translate_custom']);
};
//transalte handler for layer_translate()
this.layer_translate_custom = function(user_response){
EDIT.save_state();
var x = parseInt(user_response.x);
var y = parseInt(user_response.y);
//move
var tmp = canvas_active().getImageData(0, 0, WIDTH, HEIGHT);
canvas_active().clearRect(0, 0, WIDTH, HEIGHT);
canvas_active().putImageData(tmp, x, y);
};
//removes all layers
this.remove_all_layers = function(){
//delete old layers