|
1182 | 1182 | exports._doStroke = _doStroke; |
1183 | 1183 | }); |
1184 | 1184 |
|
| 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 | + |
1185 | 1198 | var RealDrawBoard_1 = createCommonjsModule(function (module, exports) { |
1186 | 1199 | var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { |
1187 | 1200 | var extendStatics = function (d, b) { |
|
1230 | 1243 |
|
1231 | 1244 |
|
1232 | 1245 |
|
| 1246 | + |
1233 | 1247 | var RealDrawBoard = /** @class */ (function (_super) { |
1234 | 1248 | __extends(RealDrawBoard, _super); |
1235 | 1249 | function RealDrawBoard(options) { |
|
1250 | 1264 | _this._startStroke = stroke._startStroke; |
1251 | 1265 | _this._endStroke = stroke._endStroke; |
1252 | 1266 | _this._doStroke = stroke._doStroke; |
| 1267 | + _this._getMouseCoords = _coords._getMouseCoords; |
1253 | 1268 | _this.undo = undo_1.undo; |
1254 | 1269 | _this.redo = undo_1.redo; |
1255 | 1270 | _this.changeBrushColor = boardManip.changeBrushColor; |
1256 | 1271 | _this.changeBrushSize = boardManip.changeBrushSize; |
1257 | 1272 | _this.changeEraserSize = boardManip.changeEraserSize; |
1258 | 1273 | _this.changeMode = boardManip.changeMode; |
1259 | 1274 | _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 | | - }; |
1267 | 1275 | _this._mouseDownEventListener = function (e) { |
1268 | 1276 | if (e.button === 0 /* Left Click */) { |
1269 | 1277 | _this.canvas.addEventListener('mousemove', _this._mouseMoveEventListener); |
1270 | | - _this._startStroke(_this._getCoords(e)); |
| 1278 | + _this._startStroke(_this._getMouseCoords(e)); |
1271 | 1279 | } |
1272 | 1280 | }; |
1273 | 1281 | _this._mouseUpEventListener = function (e) { |
1274 | 1282 | if (e.button === 0 /* Left Click */) { |
1275 | | - var endCoords = _this._getCoords(e); |
| 1283 | + var endCoords = _this._getMouseCoords(e); |
1276 | 1284 | _this._endStroke(endCoords); |
1277 | 1285 | } |
1278 | 1286 | }; |
1279 | 1287 | _this._mouseEnterEventListener = function (e) { |
1280 | | - _this._lastCoords = _this._getCoords(e); |
| 1288 | + _this._lastCoords = _this._getMouseCoords(e); |
1281 | 1289 | }; |
1282 | 1290 | _this._mouseLeaveEventListener = function (e) { |
1283 | | - _this._endStroke(_this._getCoords(e)); |
| 1291 | + _this._endStroke(_this._getMouseCoords(e)); |
1284 | 1292 | }; |
1285 | 1293 | _this._mouseMoveEventListener = function (e) { |
1286 | | - var coords = _this._getCoords(e); |
| 1294 | + var coords = _this._getMouseCoords(e); |
1287 | 1295 | _this._doStroke(coords); |
1288 | 1296 | }; |
1289 | 1297 | options = __assign(__assign({}, RealDrawBoardDefaults.RealDrawBoardDefaults), options); |
|
0 commit comments