Skip to content

Instantly share code, notes, and snippets.

@aranda-adapptor
Created December 24, 2020 04:46
Show Gist options
  • Save aranda-adapptor/1d5c2169aea1d8f63b3ae8257e91c7bd to your computer and use it in GitHub Desktop.
Save aranda-adapptor/1d5c2169aea1d8f63b3ae8257e91c7bd to your computer and use it in GitHub Desktop.
// 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