Skip to content

Commit 3c98bac

Browse files
add: fractal colors
1 parent a9b63a8 commit 3c98bac

7 files changed

Lines changed: 48 additions & 9 deletions

File tree

TODO.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# To Do List
22

3-
Add iCloud Icons extension and TrackMySpa to projects list?
3+
Redo styling
4+
Remove julia code from homepage, perhaps bake the animation
5+
Actually make it interesting
6+
Use catpuccin colours
7+
8+
Move various projects into their own repos
9+
410
ASMR sound generator
511
Julia
6-
Calculator
7-
Games
812

913
- Make the mobile version better
1014
- Make page transitions

src/lib/julia/julia-config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ export const defaultConfig: Config = {
1414
maxIterations: 100,
1515
radius: 4,
1616

17-
fractalColorR: 180,
18-
fractalColorG: 111,
19-
fractalColorB: 214,
17+
// TODO: rename to falloff colour
18+
fractalColorR: 180 / 255,
19+
fractalColorG: 111 / 255,
20+
fractalColorB: 214 / 255,
2021
fractalColorA: 1,
22+
fractalColorStrength: 255,
23+
2124
backgroundColorR: 0,
2225
backgroundColorG: 0,
2326
backgroundColorB: 0,
@@ -69,6 +72,8 @@ export interface Config {
6972
fractalColorG: number;
7073
fractalColorB: number;
7174
fractalColorA: number;
75+
fractalColorStrength: number;
76+
7277
backgroundColorR: number;
7378
backgroundColorG: number;
7479
backgroundColorB: number;

src/lib/julia/julia-renderer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ export default class JuliaRenderer {
162162
);
163163

164164
// Color
165+
this.uniformLocations.fractalColorStrength = gl.getUniformLocation(
166+
this.program,
167+
"uFractalColorStrength",
168+
);
169+
165170
this.uniformLocations.fractalColor = gl.getUniformLocation(
166171
this.program,
167172
"uFractalColor",
@@ -265,6 +270,7 @@ export default class JuliaRenderer {
265270
const config = this.config;
266271

267272
// Update color settings
273+
gl.uniform1f(uniforms.fractalColorStrength, config.fractalColorStrength);
268274
gl.uniform4f(uniforms.fractalColor, config.fractalColorR, config.fractalColorG, config.fractalColorB, config.fractalColorA);
269275
gl.uniform4f(uniforms.backgroundColor, config.backgroundColorR, config.backgroundColorG, config.backgroundColorB, config.backgroundColorA);
270276

src/lib/julia/shaders/frag.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ precision highp float;
33

44
{{uniforms}}
55

6+
uniform float uFractalColorStrength;
67
uniform vec4 uFractalColor;
78
uniform vec4 uBackgroundColor;
89

@@ -52,5 +53,5 @@ void main() {
5253
}
5354

5455
// Calculate final color
55-
FragColor = mix(uBackgroundColor, uFractalColor, vec4(pixelValue));
56+
FragColor = mix(uBackgroundColor, uFractalColor * uFractalColorStrength, vec4(pixelValue));
5657
}

src/lib/style/variables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--font: -apple-system, BlinkMacSystemFont, "Poppins", sans-serif;
66
--font-heading: "Consolas", monospace;
77

8-
/* Colours */
8+
/* Colors */
99
--col-text: #f1f1f1;
1010
--col-heading: white;
1111
--col-bg: #0a0a16;

src/routes/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
// TODO: clean up the animation itself
1515
// Either just make a cool animation or make it shape into my pfp
16-
// Use these colours
16+
// Use these colors
1717
/*
1818
--col-rainbow-1: #df406f;
1919
--col-rainbow-2: #fbda34;

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,29 @@
375375
<NumberInput bind:value={config.radius} min={1} max={1000} step={0.01}>
376376
Escape Radius - How far a point must travel to be considered part of the set
377377
</NumberInput>
378+
379+
<h2>Falloff</h2>
380+
381+
<h2>Falloff Color</h2>
382+
<NumberInput bind:value={config.fractalColorR} min={0} max={1} step={0.01}>R</NumberInput>
383+
<NumberInput bind:value={config.fractalColorG} min={0} max={1} step={0.01}>G</NumberInput>
384+
<NumberInput bind:value={config.fractalColorB} min={0} max={1} step={0.01}>B</NumberInput>
385+
<NumberInput bind:value={config.fractalColorA} min={0} max={1} step={0.01}>A</NumberInput>
386+
<NumberInput bind:value={config.fractalColorStrength} min={0} max={1000} step={0.01}>Strength (allows blowing out)</NumberInput>
387+
388+
<h2>Background Color</h2>
389+
<NumberInput bind:value={config.backgroundColorR} min={0} max={1} step={0.01}>R</NumberInput>
390+
<NumberInput bind:value={config.backgroundColorG} min={0} max={1} step={0.01}>G</NumberInput>
391+
<NumberInput bind:value={config.backgroundColorB} min={0} max={1} step={0.01}>B</NumberInput>
392+
<NumberInput bind:value={config.backgroundColorA} min={0} max={1} step={0.01}>A</NumberInput>
393+
394+
<h2>Set Color</h2>
395+
<ToggleInput bind:value={config.useSetColorOverValue}>Whether to use the color provided below for pixels in the set, or to pretend that pixels in the set have the value provided below.</ToggleInput>
396+
<NumberInput bind:value={config.setValue} min={0} max={1} step={0.01}>The value of pixels in the set</NumberInput>
397+
<NumberInput bind:value={config.setColorR} min={0} max={1} step={0.01}>R</NumberInput>
398+
<NumberInput bind:value={config.setColorG} min={0} max={1} step={0.01}>G</NumberInput>
399+
<NumberInput bind:value={config.setColorB} min={0} max={1} step={0.01}>B</NumberInput>
400+
<NumberInput bind:value={config.setColorA} min={0} max={1} step={0.01}>A</NumberInput>
378401
</div>
379402
</div>
380403
{/if}

0 commit comments

Comments
 (0)