Skip to content

Commit

Permalink
Add validation to getOverlappingPixelIndices function
Browse files Browse the repository at this point in the history
  • Loading branch information
hunkim98 committed Jul 15, 2023
1 parent 2fa5b15 commit 088a40c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ export const getOverlappingPixelIndicesForModifiedPixels = (
modifyPixelHeightRatio: number,
gridSquareLength: number,
) => {
if (modifyPixelHeightRatio < 0 || modifyPixelWidthRatio < 0) {
throw new Error(
"modifyPixelHeightRatio and modifyPixelWidthRatio should be positive",
);
}
if (gridSquareLength < 0) {
throw new Error("gridSquareLength should be positive");
}
const pixelsToColor: Array<ColorChangeItem> = [];
for (const item of originalPixels) {
const pixelDistanceFromOrigin = {
Expand Down

0 comments on commit 088a40c

Please sign in to comment.