MCPcopy
hub / github.com/viliusle/miniPaint / shape_mousedown

Method shape_mousedown

src/js/core/base-tools.js:393–431  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

391 }
392
393 shape_mousedown(e) {
394 var mouse = this.get_mouse_info(e);
395 if (mouse.click_valid == false)
396 return;
397
398 var mouse_x = mouse.x;
399 var mouse_y = mouse.y;
400
401 //apply snap
402 var snap_info = this.calc_snap_position(e, mouse_x, mouse_y);
403 if(snap_info != null){
404 if(snap_info.x != null) {
405 mouse_x = snap_info.x;
406 }
407 if(snap_info.y != null) {
408 mouse_y = snap_info.y;
409 }
410 }
411
412 this.shape_mouse_click.x = mouse_x;
413 this.shape_mouse_click.y = mouse_y;
414
415 //register new object - current layer is not ours or params changed
416 this.layer = {
417 type: this.name,
418 params: this.clone(this.getParams()),
419 status: 'draft',
420 render_function: [this.name, 'render'],
421 x: Math.round(mouse_x),
422 y: Math.round(mouse_y),
423 color: null,
424 is_vector: true
425 };
426 app.State.do_action(
427 new app.Actions.Bundle_action('new_'+this.name+'_layer', 'New '+this.Helper.ucfirst(this.name)+' Layer', [
428 new app.Actions.Insert_layer_action(this.layer)
429 ])
430 );
431 }
432
433 shape_mousemove(e) {
434 var mouse = this.get_mouse_info(e);

Callers 15

mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80
mousedownMethod · 0.80

Calls 6

get_mouse_infoMethod · 0.95
calc_snap_positionMethod · 0.95
cloneMethod · 0.95
getParamsMethod · 0.95
do_actionMethod · 0.80
ucfirstMethod · 0.80

Tested by

no test coverage detected