MCPcopy Create free account
hub / github.com/devforth/painterro / handleMouseDown

Method handleMouseDown

js/primitive.js:40–73  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

38 }
39
40 handleMouseDown(event) {
41 this.activate(this.type);
42 const mainClass = event.target.classList[0];
43
44 this.ctx.lineWidth = this.lineWidth;
45 this.ctx.strokeStyle = this.main.colorWidgetState.line.alphaColor;
46 this.ctx.fillStyle = this.main.colorWidgetState.fill.alphaColor;
47 const scale = this.main.getScale();
48 this.ctx.lineCap = 'round';
49 if (mainClass === 'ptro-crp-el' || mainClass === 'ptro-zoomer') {
50 this.tmpData = this.ctx.getImageData(0, 0, this.main.size.w, this.main.size.h);
51 if (this.type === 'brush' || this.type === 'eraser') {
52 this.state.cornerMarked = true;
53 const cord = [
54 (event.clientX - this.main.elLeft()) + this.main.scroller.scrollLeft,
55 (event.clientY - this.main.elTop()) + this.main.scroller.scrollTop,
56 ];
57 const cur = {
58 x: cord[0] * scale,
59 y: cord[1] * scale,
60 };
61
62 this.points = [cur];
63 this.drawBrushPath();
64 } else {
65 this.state.cornerMarked = true;
66 this.centerCord = [
67 (event.clientX - this.main.elLeft()) + this.main.scroller.scrollLeft,
68 (event.clientY - this.main.elTop()) + this.main.scroller.scrollTop,
69 ];
70 this.centerCord = [this.centerCord[0] * scale, this.centerCord[1] * scale];
71 }
72 }
73 }
74
75 drawBrushPath() {
76 const smPoints = this.points;

Callers

nothing calls this directly

Calls 5

activateMethod · 0.95
drawBrushPathMethod · 0.95
elLeftMethod · 0.80
elTopMethod · 0.80
getScaleMethod · 0.45

Tested by

no test coverage detected