-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from mateoguzmana/chore/multiple-fixes
feat(canvas): adding pointerEvents as none by default
- Loading branch information
Showing
4 changed files
with
51 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
import { screenWidth, screenHeight } from '../constants/dimensions'; | ||
|
||
export function fromRadians(angle: number) { | ||
return angle * (180.0 / Math.PI); | ||
} | ||
|
||
export function generateRandomCoordinates( | ||
numElements: number | ||
): Array<{ x: number; y: number }> { | ||
// Create an array to store the generated coordinates | ||
const coordinates: Array<{ x: number; y: number }> = []; | ||
|
||
// Generate random x,y coordinates until we have the desired number of elements | ||
while (coordinates.length < numElements) { | ||
// Generate a random x,y coordinate | ||
const x = Math.random() * screenWidth; | ||
const y = Math.random() * screenHeight; | ||
|
||
// Check if the coordinate is unique | ||
let unique = true; | ||
for (const { x: prevX, y: prevY } of coordinates) { | ||
if (prevX === x && prevY === y) { | ||
unique = false; | ||
break; | ||
} | ||
} | ||
|
||
// If the coordinate is unique, add it to the array of coordinates | ||
if (unique) { | ||
coordinates.push({ x, y }); | ||
} | ||
} | ||
|
||
return coordinates; | ||
} |