-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
179 lines (178 loc) · 7.42 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<head>
<title>FLAM3 on WebGPU</title>
<script type="module" src="main.js">
</script>
<meta http-equiv="origin-trial" content="ApM25sNacnr2j5CSBQo9nFS9kwa4f6QxnNz9RQJF9B2IhcsSvH/VDUM64WbQY4uAGpoXxU35Xi9G4KKmFmxaQQ4AAABUeyJvcmlnaW4iOiJodHRwczovL2lnbG9zaWdnaW8uZ2l0aHViLmlvOjQ0MyIsImZlYXR1cmUiOiJXZWJHUFUiLCJleHBpcnkiOjE2OTE3MTE5OTl9">
<style>
body {
font-family: sans-serif;
margin: 0;
background-color: rgb(255, 255, 255);
}
.intro {
margin: auto;
max-width: 700px;
}
.intro h1, .intro h2, .intro h3 {
text-align: right;
line-height: 0.5em;
}
main {
width: 100%;
text-align: center;
background-color: rgb(72, 61, 139);
}
#fractal-viewer, #xforms {
display: inline-block;
vertical-align: middle;
margin-top: 0.4em;
margin-bottom: 0.4em;
}
#controls {
text-align: center;
}
#xforms {
background-color: rgb(166, 152, 252);
border-radius: 0px 10px 30px 10px;
}
xform-editor, #add-xform {
text-align: left;
display: block;
padding: 1em 1em;
border-color: rgb(72, 61, 139);
border-style: dashed;
border-width: 0.0em 0em 0.01em 0em;
}
xform-editor:last-child {
border-width: 0em;
}
#add-xform {
border-radius: 0px 10px 0px 0px;
text-align: center;
width: 100%;
background-color: transparent;
}
#add-xform:hover {
background-color: rgba(255, 255, 255, 0.25);
}
#add-xform:active {
background-color: rgba(255, 255, 255, 0.5);
}
</style>
</head>
<body>
<template id="xform-editor-template">
<style>
.editor-element {
display: block;
margin-top: 0.2em;
}
.vector {
vertical-align: middle;
display: inline-block;
border-color: black;
border-style: solid;
border-width: 0em 0.01em 0em 0.01em;
border-radius: 0.3em;
}
.affine-transform {
min-width: 200px;
}
.vector td {
text-align: right;
}
.remove-button {
text-align: center;
}
</style>
<label class="editor-element">
<i>Variation:</i>
<select name="variation-selector">
</select>
</label>
<label class="editor-element">
<i>Color:</i>
<input type="range" name="color" id="price" min="0" max="1" step="0.0001" value="0">
</label>
<div class="affine-transform editor-element">
<table class="vector">
<tr>
<td><slot name="a">a</slot></td>
<td><slot name="b">b</slot></td>
</tr>
<tr>
<td><slot name="d">d</slot></td>
<td><slot name="e">e</slot></td>
</tr>
</table>
<table class="vector">
<tr><td>x</td></tr>
<tr><td>y</td></tr>
</table>
+
<table class="vector">
<tr><td><slot name="c">c</slot></td></tr>
<tr><td><slot name="f">f</slot></td></tr>
</table>
</div>
<div class="editor-element remove-button">
<button>Remove</button>
</div>
</template>
<main>
<h1 id="webgpu-not-supported-error" style="display: none;">WebGPU support was not detected</h1>
<h1 id="webgpu-no-device-error" style="display: none;">No WebGPU device is available</h1>
<div id="fractal-viewer">
<canvas id="output" width="900" height="900">
Sorry, your browser has no canvas support
</canvas>
<div id="controls">
<button onclick="flam3.start()" id="flam3-start">Start </button>
<button onclick="flam3.stop()" id="flam3-stop" >Stop </button>
<button onclick="flam3.step()" id="flam3-step" >Step </button>
<button onclick="flam3.clear()" id="flam3-clear">Clear </button>
<button onclick="flam3.gui = !flam3.gui" id="flam3-gui" >Toggle GUI</button>
<select id="flam3-cmap">
</select>
</div>
</div>
<div id="xforms">
<button id="add-xform">Add XForm</button>
</div>
</main>
<div class="intro">
<h1>What the hell is that?</h1>
<h2>Alternative title: <i>"Easy FLAM3 fractal rendering on WebGPU"</i></h2>
<h3>by mega</h3>
<p>At some point I will put some explanation of how the implementation works and what the triangles mean. For now you can check the <a href="https://flam3.com/flame_draves.pdf">original paper</a> and the <a href="https://github.com/iglosiggio/flam3-webgpu">sources for this site</a>. If something is still unclear feel free to reach out to me :)</p>
<p>The implementation is made on <a href="https://tc39.es/ecma262/">JavaScript</a> and <a href="https://gpuweb.github.io/gpuweb/">WebGPU</a> (using <a href="https://gpuweb.github.io/gpuweb/wgsl/">WGSL</a> shaders).</p>
</div>
<script type="text/javascript">
customElements.define('xform-editor', class extends HTMLElement {
static get observedAttributes() {
return ['variation', 'color', 'a', 'b', 'c', 'd', 'e', 'f']
}
constructor() {
super();
const template = document.getElementById('xform-editor-template')
.content;
this.attachShadow({mode: 'open'})
.appendChild(template.cloneNode(true));
}
attributeChangedCallback(name, oldValue, newValue) {
if (this.constructor.observedAttributes.includes(name))
if (name === 'variation')
this.shadowRoot.querySelector('select').value = newValue
else if (name === 'color')
this.shadowRoot.querySelector('input[name="color"]').value = newValue
else
this.shadowRoot.querySelector(`slot[name="${name}"]`).textContent = newValue
else
console.warn(`Unknown attribute ${name} changed from ${oldValue} to ${newValue}`)
}
});
</script>
</body>
</html>