Skip to content

Commit

Permalink
Handle selection with width/height smaller than 3
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed Sep 19, 2024
1 parent b16eb1f commit 03ca0ba
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions newIDE/app/src/InstancesEditor/TileMapPaintingPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ export const getTilesGridCoordinatesFromPointerSceneCoordinates = ({
} else if (tileMapTileSelection.kind === 'rectangle') {
const selectionTopLeftCorner = tileMapTileSelection.coordinates[0];
const selectionBottomRightCorner = tileMapTileSelection.coordinates[1];
const selectionWidth =
selectionBottomRightCorner.x - selectionTopLeftCorner.x + 1;
const selectionHeight =
selectionBottomRightCorner.y - selectionTopLeftCorner.y + 1;

if (isSelectionASingleTileRectangle(tileMapTileSelection)) {
const tileCoordinates = getTileCoordinatesOfCorner({
Expand Down Expand Up @@ -318,23 +322,19 @@ export const getTilesGridCoordinatesFromPointerSceneCoordinates = ({
}

let tileX, tileY;
const selectionWidth =
selectionBottomRightCorner.x - selectionTopLeftCorner.x + 1;
const selectionHeight =
selectionBottomRightCorner.y - selectionTopLeftCorner.y + 1;
if (deltaX === 0) {
if (deltaX === 0 || selectionWidth === 1) {
tileX = selectionTopLeftCorner.x;
} else if (invertedDeltaX === 0) {
} else if (invertedDeltaX === 0 || selectionWidth === 2) {
tileX = selectionBottomRightCorner.x;
} else {
tileX =
((deltaX - 1) % (selectionWidth - 2)) +
1 +
selectionTopLeftCorner.x;
}
if (deltaY === 0) {
if (deltaY === 0 || selectionHeight === 1) {
tileY = selectionTopLeftCorner.y;
} else if (invertedDeltaY === 0) {
} else if (invertedDeltaY === 0 || selectionHeight === 2) {
tileY = selectionBottomRightCorner.y;
} else {
tileY =
Expand Down

0 comments on commit 03ca0ba

Please sign in to comment.