MCPcopy Create free account
hub / github.com/esengine/esengine / onMouseUp

Method onMouseUp

packages/tilemap-editor/src/tools/SelectTool.ts:34–65  ·  view source on GitHub ↗
(tileX: number, tileY: number, ctx: ToolContext)

Source from the content-addressed store, hash-verified

32 }
33
34 onMouseUp(tileX: number, tileY: number, ctx: ToolContext): void {
35 if (!this._isSelecting) return;
36
37 this._currentX = tileX;
38 this._currentY = tileY;
39
40 const minX = Math.max(0, Math.min(this._startX, this._currentX));
41 const maxX = Math.min(ctx.tilemap.width - 1, Math.max(this._startX, this._currentX));
42 const minY = Math.max(0, Math.min(this._startY, this._currentY));
43 const maxY = Math.min(ctx.tilemap.height - 1, Math.max(this._startY, this._currentY));
44
45 const width = maxX - minX + 1;
46 const height = maxY - minY + 1;
47
48 const tiles: number[] = [];
49 for (let y = minY; y <= maxY; y++) {
50 for (let x = minX; x <= maxX; x++) {
51 const tileIndex = ctx.tilemap.getTile(ctx.currentLayer, x, y);
52 tiles.push(tileIndex);
53 }
54 }
55
56 useTilemapEditorStore.getState().setSelectedTiles({
57 x: minX,
58 y: minY,
59 width,
60 height,
61 tiles
62 });
63
64 this.reset();
65 }
66
67 getPreviewTiles(tileX: number, tileY: number, _ctx: ToolContext): { x: number; y: number }[] {
68 if (!this._isSelecting) {

Callers

nothing calls this directly

Calls 6

resetMethod · 0.95
getTileMethod · 0.80
pushMethod · 0.65
maxMethod · 0.45
minMethod · 0.45
getStateMethod · 0.45

Tested by

no test coverage detected