(e)
| 486 | } |
| 487 | |
| 488 | shape_mouseup(e) { |
| 489 | var mouse = this.get_mouse_info(e); |
| 490 | var params = this.getParams(); |
| 491 | |
| 492 | if (mouse.click_valid == false) { |
| 493 | config.layer.status = null; |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | var mouse_x = Math.round(mouse.x); |
| 498 | var mouse_y = Math.round(mouse.y); |
| 499 | var click_x = Math.round(this.shape_mouse_click.x); |
| 500 | var click_y = Math.round(this.shape_mouse_click.y); |
| 501 | |
| 502 | //apply snap |
| 503 | var snap_info = this.calc_snap_position(e, mouse_x, mouse_y, config.layer.id); |
| 504 | if(snap_info != null){ |
| 505 | if(snap_info.x != null) { |
| 506 | mouse_x = snap_info.x; |
| 507 | } |
| 508 | if(snap_info.y != null) { |
| 509 | mouse_y = snap_info.y; |
| 510 | } |
| 511 | } |
| 512 | this.snap_line_info = {x: null, y: null}; |
| 513 | |
| 514 | var x = Math.min(mouse_x, click_x); |
| 515 | var y = Math.min(mouse_y, click_y); |
| 516 | var width = Math.abs(mouse_x - click_x); |
| 517 | var height = Math.abs(mouse_y - click_y); |
| 518 | |
| 519 | if (e.ctrlKey == true || e.metaKey) { |
| 520 | if (width < height * this.best_ratio) { |
| 521 | width = height * this.best_ratio; |
| 522 | } |
| 523 | else { |
| 524 | height = width / this.best_ratio; |
| 525 | } |
| 526 | if (mouse_x < click_x) { |
| 527 | x = click_x - width; |
| 528 | } |
| 529 | if (mouse_y < click_y) { |
| 530 | y = click_y - height; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | if (width == 0 && height == 0) { |
| 535 | //same coordinates - cancel |
| 536 | app.State.scrap_last_action(); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | //more data |
| 541 | app.State.do_action( |
| 542 | new app.Actions.Update_layer_action(config.layer.id, { |
| 543 | x, |
| 544 | y, |
| 545 | width, |
no test coverage detected