|
11 | 11 | import ToggleInput from "$lib/components/ToggleInput.svelte"; |
12 | 12 |
|
13 | 13 | import { fly } from "svelte/transition"; |
| 14 | + import SelectInput from "$lib/components/SelectInput.svelte"; |
14 | 15 |
|
15 | 16 | // TODO: add option for axes overlay |
16 | | - // TODO: make pressing escape with fullscreen also disabled isFullscreen |
17 | 17 | // TODO: disable selecting elements with TAB when fullscreened |
18 | 18 | // TODO: add better controls for changing transform |
19 | | - // TODO: possibly disable the resolution controls, they are only needed for rendering to a specific resolution |
20 | 19 | // TOOD: sensitivity controls |
21 | 20 | // TODO: add a focus indicator |
| 21 | + // TODO: fix the select menu being shit |
22 | 22 |
|
23 | 23 | let isFullscreen = $state(false); |
24 | 24 | let showSettings = $state(false); |
25 | 25 |
|
26 | 26 | let navbar: HTMLElement; |
27 | 27 |
|
| 28 | + const fractalTypes = Object.keys(FractalType) |
| 29 | + .filter(key => typeof FractalType[key as any] === 'number') |
| 30 | + .map(key => ({ id: FractalType[key as any], name: key })); |
| 31 | +
|
28 | 32 | // Resize the canvas if we entered fullscreen |
29 | 33 | function handleResize() { |
30 | 34 | if (!isFullscreen) { |
|
38 | 42 | function toggleFullscreen() { |
39 | 43 | isFullscreen = !isFullscreen; |
40 | 44 |
|
| 45 | + // Focus canvas and reset canvas size |
41 | 46 | if (isFullscreen) { |
42 | | - document.documentElement.requestFullscreen(); |
43 | 47 | canvas.focus(); |
| 48 | + handleResize(); |
44 | 49 | } |
45 | 50 | else { |
46 | | - document.exitFullscreen(); |
47 | | -
|
48 | | - // Reset canvas size |
49 | 51 | config.width = defaultConfig.width; |
50 | 52 | config.height = defaultConfig.height; |
51 | 53 | } |
|
284 | 286 | <div class="settings-window" transition:fly={{ x: '-100%', duration: 300 }}> |
285 | 287 | <div class="settings-container"> |
286 | 288 | <h2>Image</h2> |
| 289 | + |
| 290 | + <p> |
| 291 | + Avoid messing with these because they are automatically set. |
| 292 | + <br /> |
| 293 | + If you want an image at a specific resolution, fullscreen, then change the width and height. |
| 294 | + </p> |
287 | 295 |
|
288 | | - <NumberInput bind:value={config.width} min={1} max={3840} forceMinMaxNumber={true}> |
| 296 | + <NumberInput bind:value={config.width} min={1} max={3840} forceMinMaxNumber={true} disabled={!isFullscreen}> |
289 | 297 | Width |
290 | 298 | </NumberInput> |
291 | 299 |
|
292 | | - <NumberInput bind:value={config.height} min={1} max={3840} forceMinMaxNumber={true}> |
| 300 | + <NumberInput bind:value={config.height} min={1} max={3840} forceMinMaxNumber={true} disabled={!isFullscreen}> |
293 | 301 | Height |
294 | 302 | </NumberInput> |
295 | | - |
296 | | - <h2>Coordinates</h2> |
297 | 303 |
|
298 | | - <p>Hold J to change the coordinates with the mouse</p> |
299 | | - |
300 | | - <NumberInput bind:value={config.real} min={-3} max={3} step={0.01}> |
301 | | - Real Component |
302 | | - </NumberInput> |
303 | | - |
304 | | - <NumberInput bind:value={config.imaginary} min={-3} max={3} step={0.01}> |
305 | | - Imaginary Component |
306 | | - </NumberInput> |
| 304 | + <h2>Fractal Type</h2> |
| 305 | + |
| 306 | + <SelectInput bind:value={config.fractal} options={fractalTypes}> |
| 307 | + Fractal |
| 308 | + </SelectInput> |
| 309 | + |
| 310 | + {#if config.fractal === FractalType.Julia} |
| 311 | + <h2>Julia Coordinates</h2> |
| 312 | + |
| 313 | + <p>Hold J to change the coordinates with the mouse.</p> |
| 314 | + |
| 315 | + <NumberInput bind:value={config.real} min={-3} max={3} step={0.01}> |
| 316 | + Real Component |
| 317 | + </NumberInput> |
| 318 | + |
| 319 | + <NumberInput bind:value={config.imaginary} min={-3} max={3} step={0.01}> |
| 320 | + Imaginary Component |
| 321 | + </NumberInput> |
| 322 | + {/if} |
| 323 | + |
| 324 | + {#if config.fractal === FractalType.Mandelbrot} |
| 325 | + <h2>Mandelbrot Exponent</h2> |
| 326 | + |
| 327 | + <p>Negative and fractional exponents are allowed.</p> |
| 328 | + |
| 329 | + <NumberInput bind:value={config.exponent} min={-5} max={5} step={0.01}> |
| 330 | + Exponent |
| 331 | + </NumberInput> |
| 332 | + {/if} |
307 | 333 |
|
308 | 334 | <h2>Transformation</h2> |
309 | 335 |
|
|
322 | 348 | <NumberInput bind:value={config.scale} min={0.01} max={15} step={0.01}> |
323 | 349 | Scale |
324 | 350 | </NumberInput> |
| 351 | + |
| 352 | + <h2>Renderer</h2> |
| 353 | + |
| 354 | + <NumberInput bind:value={config.maxIterations} min={1} max={1000} step={1}> |
| 355 | + Iterations - Higher means more quality but slower |
| 356 | + </NumberInput> |
| 357 | + |
| 358 | + <NumberInput bind:value={config.radius} min={1} max={1000} step={0.01}> |
| 359 | + Escape Radius - How far a point must travel to be considered part of the set |
| 360 | + </NumberInput> |
325 | 361 | </div> |
326 | 362 | </div> |
327 | 363 | {/if} |
|
434 | 470 | flex-direction: column; |
435 | 471 | align-items: center; |
436 | 472 | gap: 0.5em; |
| 473 | +
|
| 474 | + p { |
| 475 | + text-align: center; |
| 476 | + } |
437 | 477 | } |
438 | 478 | } |
439 | 479 | } |
|
0 commit comments