Created
December 24, 2020 04:46
-
-
Save aranda-adapptor/1d5c2169aea1d8f63b3ae8257e91c7bd to your computer and use it in GitHub Desktop.
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
// Split the static star data out from the props type | |
interface StarData { | |
id: number; | |
x: number; | |
y: number; | |
} | |
interface StarProps extends StarData { | |
time: Animated.SharedValue<number>; | |
} | |
// Build an array of star data and spread them across the screen | |
const stars: StarData[] = []; | |
const starCount = 50; | |
const windowWidth = Dimensions.get("window").width; | |
const windowHeight = Dimensions.get("window").height; | |
for (var i = 0; i < starCount; i++) { | |
stars.push({ | |
id: i, | |
x: windowWidth / 2 + windowWidth * (Math.random() - 0.5), | |
y: windowHeight / 2 + windowHeight * (Math.random() - 0.5), | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment