Skip to content

Commit eaffc63

Browse files
authored
Update index.html
1 parent ee3979f commit eaffc63

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ <h3>Import Options</h3>
686686
const canvas = $("glCanvas");
687687
const gl = canvas.getContext("webgl", { stencil: true });
688688
if (!gl) alert("WebGL not supported by your browser.");
689-
689+
gl.enable(gl.BLEND);
690+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA,
691+
gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
690692
/* -----------------------------------
691693
GLOBALS & DATA
692694
----------------------------------- */
@@ -1299,6 +1301,7 @@ <h3>Import Options</h3>
12991301

13001302
// 3) toggle only that blob
13011303
chains[bestIndex].frozen = !chains[bestIndex].frozen;
1304+
chains[bestIndex].alpha = chains[bestIndex].frozen ? 0.3 : 1.0;
13021305
}
13031306
return;
13041307
}
@@ -1862,6 +1865,10 @@ <h3>Import Options</h3>
18621865
gl.uniform4fv(lineColorLoc, chainObj.color); // colour doesn’t matter
18631866
gl.drawArrays(gl.TRIANGLES, 0, tris.length / 2);
18641867

1868+
const rgba = chainObj.color.slice(); // copy
1869+
rgba[3] = chainObj.alpha ?? 1.0; // use 0.3 if frozen
1870+
gl.uniform4fv(lineColorLoc, rgba);
1871+
18651872
// 2) draw one big quad wherever stencil==1 (the filled blob)
18661873
gl.colorMask(true, true, true, true);
18671874
gl.stencilFunc(gl.EQUAL, 1, 1);

0 commit comments

Comments
 (0)