Skip to content

Commit bf8b76a

Browse files
Improve julia settings further
1 parent 4bcb58a commit bf8b76a

4 files changed

Lines changed: 117 additions & 19 deletions

File tree

src/lib/components/NumberInput.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import type { Snippet } from "svelte";
33
4+
// TODO: add colouring for being disabled
45
interface Props {
56
children: Snippet,
67
value: number,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<script lang="ts">
2+
import type { Snippet } from "svelte";
3+
4+
interface Props {
5+
children: Snippet,
6+
value: any,
7+
options: { id: any, name: string }[],
8+
}
9+
10+
let { children, value = $bindable(), options }: Props = $props();
11+
</script>
12+
13+
<!-- TODO: dropdown arrow -->
14+
<div class="input">
15+
<select bind:value={value}>
16+
{#each options as option (option.id)}
17+
<option value={option.id}>{option.name}</option>
18+
{/each}
19+
</select>
20+
21+
<label>{@render children()}</label>
22+
</div>
23+
24+
<style>
25+
.input {
26+
display: flex;
27+
align-items: center;
28+
justify-content: space-between;
29+
width: 100%;
30+
31+
& > div {
32+
display: flex;
33+
align-items: center;
34+
justify-content: space-between;
35+
gap: 1em;
36+
}
37+
}
38+
39+
select {
40+
appearance: none;
41+
-webkit-appearance: none;
42+
43+
width: 10em;
44+
background-color: var(--col-fg);
45+
border: var(--border);
46+
border-radius: 1000rem;
47+
padding: 0.25em 0.5em;
48+
49+
option {
50+
background-color: var(--col-fg);
51+
border: var(--border);
52+
border-radius: 1000rem;
53+
padding: 0.25em 0.5em;
54+
}
55+
}
56+
</style>

src/lib/julia/fractals/mandlebrot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const functionDetails = {
2626
2727
// Update position
2828
// TODO: innefficient
29+
// TODO: allow doing exponent with julia
2930
//float tempX = x * x - y * y + cx;
3031
//y = 2.0 * x * y + cy;
3132
float tempX = pow((x * x + y * y), uExponent / 2.0) * cos(uExponent * atan(y, x)) + cx;

src/routes/projects/julia/+page.svelte

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@
1111
import ToggleInput from "$lib/components/ToggleInput.svelte";
1212
1313
import { fly } from "svelte/transition";
14+
import SelectInput from "$lib/components/SelectInput.svelte";
1415
1516
// TODO: add option for axes overlay
16-
// TODO: make pressing escape with fullscreen also disabled isFullscreen
1717
// TODO: disable selecting elements with TAB when fullscreened
1818
// TODO: add better controls for changing transform
19-
// TODO: possibly disable the resolution controls, they are only needed for rendering to a specific resolution
2019
// TOOD: sensitivity controls
2120
// TODO: add a focus indicator
21+
// TODO: fix the select menu being shit
2222
2323
let isFullscreen = $state(false);
2424
let showSettings = $state(false);
2525
2626
let navbar: HTMLElement;
2727
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+
2832
// Resize the canvas if we entered fullscreen
2933
function handleResize() {
3034
if (!isFullscreen) {
@@ -38,14 +42,12 @@
3842
function toggleFullscreen() {
3943
isFullscreen = !isFullscreen;
4044
45+
// Focus canvas and reset canvas size
4146
if (isFullscreen) {
42-
document.documentElement.requestFullscreen();
4347
canvas.focus();
48+
handleResize();
4449
}
4550
else {
46-
document.exitFullscreen();
47-
48-
// Reset canvas size
4951
config.width = defaultConfig.width;
5052
config.height = defaultConfig.height;
5153
}
@@ -284,26 +286,50 @@
284286
<div class="settings-window" transition:fly={{ x: '-100%', duration: 300 }}>
285287
<div class="settings-container">
286288
<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>
287295

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}>
289297
Width
290298
</NumberInput>
291299

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}>
293301
Height
294302
</NumberInput>
295-
296-
<h2>Coordinates</h2>
297303

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}
307333

308334
<h2>Transformation</h2>
309335

@@ -322,6 +348,16 @@
322348
<NumberInput bind:value={config.scale} min={0.01} max={15} step={0.01}>
323349
Scale
324350
</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>
325361
</div>
326362
</div>
327363
{/if}
@@ -434,6 +470,10 @@
434470
flex-direction: column;
435471
align-items: center;
436472
gap: 0.5em;
473+
474+
p {
475+
text-align: center;
476+
}
437477
}
438478
}
439479
}

0 commit comments

Comments
 (0)