react-native-fiesta
Version:
A set of celebration animations powered by Skia. Engage more with your users by celebrating in your React Native application.
37 lines (34 loc) • 1.05 kB
JavaScript
import { screenWidth, screenHeight } from '../constants/dimensions';
export function fromRadians(angle) {
return angle * (180.0 / Math.PI);
}
export function generateRandomCoordinates(numElements, specificHeight, specificWidth) {
// Create an array to store the generated coordinates
const coordinates = [];
// 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() * (specificWidth ?? screenWidth);
const y = Math.random() * (specificHeight ?? 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;
}
//# sourceMappingURL=fireworks.js.map