diff --git a/client/src/components/world_tree.tsx b/client/src/components/world_tree.tsx index bb55fc4..5e3b922 100644 --- a/client/src/components/world_tree.tsx +++ b/client/src/components/world_tree.tsx @@ -30,6 +30,9 @@ const ds = .75 // scale the resulting svg image const NMIN = 5 // min. worldsize const NLABEL = 8 // max. world size to display label below the world const NMAX = 16 // max. world size. Level icons start spiraling out if the world has more levels. +const NSPIRAL = 12 // world size if NMAX has been passed and need to spiral. + +const MINFONT = 12 // colours const grey = '#999' @@ -54,8 +57,9 @@ export function LevelIcon({ world, level, position, completed, unlocked, worldSi const N = Math.max(worldSize, NMIN) - // divide circle into `N+2` equal pieces - const beta = 2 * Math.PI / Math.min(N+2, (NMAX+1)) + // divide circle into `N+2` equal pieces. + // only for non-spiraling case + const beta = 2 * Math.PI / Math.min(N+2, ((N < (NMAX+1) ? NMAX : NSPIRAL)+1)) // We want distance between two level icons to be `2.2*r`, therefore: // Sinus-Satz: (1.1*r) / sin(β/2) = R / sin(π/2) @@ -70,19 +74,19 @@ export function LevelIcon({ world, level, position, completed, unlocked, worldSi * works fine in tests up to `N=30`. */ function betaSpiral(level) { - return 2 * Math.PI / ((NMAX+1) + Math.max(0, (level-2)) / (NMAX+1)) + return 2 * Math.PI / ((NSPIRAL+1) + 2 * Math.max(0, (level-2)) / (NSPIRAL+1)) } const x = N < (NMAX+1) ? // normal case s * position.x + Math.sin(level * beta) * R : // spiraling case - s * position.x + Math.sin(level * betaSpiral(level)) * (R + 2*r*(level-1)/(NMAX+1)) + s * position.x + Math.sin(level * betaSpiral(level)) * (R + 2*r*(level-1)/(NSPIRAL+1)) const y = N < (NMAX+1) ? // normal case s * position.y - Math.cos(level * beta) * R : // spiraling case - s * position.y - Math.cos(level * betaSpiral(level)) * (R + 2*r*(level-1)/(NMAX+1)) + s * position.y - Math.cos(level * betaSpiral(level)) * (R + 2*r*(level-1)/(NSPIRAL+1)) return ( - {worldSize > NLABEL ? + { false ? // fontSize >= MINFONT ? + // NOTE: This code would display the world names inside the bubble, but currently + // it isn't used. // Label for large worlds
-

+

{title ? title : world}

@@ -153,7 +161,7 @@ export function WorldIcon({world, title, position, completedLevels, difficulty, width='150px' height='2em' style={{overflow: 'visible'}} >
-

+

{title ? title : world}