MCPcopy Create free account
hub / github.com/NianBroken/Firework_Simulator / getRandomShellSize

Function getRandomShellSize

js/script.js:879–892  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

877
878// 获取随机的烟花尺寸
879function getRandomShellSize() {
880 const baseSize = shellSizeSelector();
881 const maxVariance = Math.min(2.5, baseSize);
882 const variance = Math.random() * maxVariance;
883 const size = baseSize - variance;
884 const height = maxVariance === 0 ? Math.random() : 1 - variance / maxVariance;
885 const centerOffset = Math.random() * (1 - height * 0.65) * 0.5;
886 const x = Math.random() < 0.5 ? 0.5 - centerOffset : 0.5 + centerOffset;
887 return {
888 size,
889 x: fitShellPositionInBoundsH(x),
890 height: fitShellPositionInBoundsV(height),
891 };
892}
893
894// Launches a shell from a user pointer event, based on state.config
895function launchShellFromConfig(event) {

Callers 3

seqRandomShellFunction · 0.85
seqRandomFastShellFunction · 0.85
seqTwoRandomFunction · 0.85

Calls 3

shellSizeSelectorFunction · 0.85

Tested by

no test coverage detected