Skip to content

Commit ae3813e

Browse files
author
HarshKhandeparkar
committed
refactor<RealDrawBoard>: .
1 parent 6f1e461 commit ae3813e

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

dist/gpujs-real-renderer-browser.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,19 @@
11821182
exports._doStroke = _doStroke;
11831183
});
11841184

1185+
var _coords = createCommonjsModule(function (module, exports) {
1186+
Object.defineProperty(exports, "__esModule", { value: true });
1187+
exports._getMouseCoords = void 0;
1188+
function _getMouseCoords(e) {
1189+
var x = e.offsetX; // in pixels
1190+
var y = this.dimensions[1] - e.offsetY; // in pixels
1191+
x = x / this.xScaleFactor - (this.dimensions[0] * (this.yOffset / 100)) / this.xScaleFactor;
1192+
y = y / this.yScaleFactor - (this.dimensions[1] * (this.xOffset / 100)) / this.yScaleFactor;
1193+
return [x, y]; // In graph coordinates
1194+
}
1195+
exports._getMouseCoords = _getMouseCoords;
1196+
});
1197+
11851198
var RealDrawBoard_1 = createCommonjsModule(function (module, exports) {
11861199
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
11871200
var extendStatics = function (d, b) {
@@ -1230,6 +1243,7 @@
12301243

12311244

12321245

1246+
12331247
var RealDrawBoard = /** @class */ (function (_super) {
12341248
__extends(RealDrawBoard, _super);
12351249
function RealDrawBoard(options) {
@@ -1250,40 +1264,34 @@
12501264
_this._startStroke = stroke._startStroke;
12511265
_this._endStroke = stroke._endStroke;
12521266
_this._doStroke = stroke._doStroke;
1267+
_this._getMouseCoords = _coords._getMouseCoords;
12531268
_this.undo = undo_1.undo;
12541269
_this.redo = undo_1.redo;
12551270
_this.changeBrushColor = boardManip.changeBrushColor;
12561271
_this.changeBrushSize = boardManip.changeBrushSize;
12571272
_this.changeEraserSize = boardManip.changeEraserSize;
12581273
_this.changeMode = boardManip.changeMode;
12591274
_this.clear = boardManip.clear;
1260-
_this._getCoords = function (e) {
1261-
var x = e.offsetX; // in pixels
1262-
var y = _this.dimensions[1] - e.offsetY; // in pixels
1263-
x = x / _this.xScaleFactor - (_this.dimensions[0] * (_this.yOffset / 100)) / _this.xScaleFactor;
1264-
y = y / _this.yScaleFactor - (_this.dimensions[1] * (_this.xOffset / 100)) / _this.yScaleFactor;
1265-
return [x, y]; // In graph coordinates
1266-
};
12671275
_this._mouseDownEventListener = function (e) {
12681276
if (e.button === 0 /* Left Click */) {
12691277
_this.canvas.addEventListener('mousemove', _this._mouseMoveEventListener);
1270-
_this._startStroke(_this._getCoords(e));
1278+
_this._startStroke(_this._getMouseCoords(e));
12711279
}
12721280
};
12731281
_this._mouseUpEventListener = function (e) {
12741282
if (e.button === 0 /* Left Click */) {
1275-
var endCoords = _this._getCoords(e);
1283+
var endCoords = _this._getMouseCoords(e);
12761284
_this._endStroke(endCoords);
12771285
}
12781286
};
12791287
_this._mouseEnterEventListener = function (e) {
1280-
_this._lastCoords = _this._getCoords(e);
1288+
_this._lastCoords = _this._getMouseCoords(e);
12811289
};
12821290
_this._mouseLeaveEventListener = function (e) {
1283-
_this._endStroke(_this._getCoords(e));
1291+
_this._endStroke(_this._getMouseCoords(e));
12841292
};
12851293
_this._mouseMoveEventListener = function (e) {
1286-
var coords = _this._getCoords(e);
1294+
var coords = _this._getMouseCoords(e);
12871295
_this._doStroke(coords);
12881296
};
12891297
options = __assign(__assign({}, RealDrawBoardDefaults.RealDrawBoardDefaults), options);

0 commit comments

Comments
 (0)