@@ -686,7 +686,9 @@ <h3>Import Options</h3>
686
686
const canvas = $ ( "glCanvas" ) ;
687
687
const gl = canvas . getContext ( "webgl" , { stencil : true } ) ;
688
688
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 ) ;
690
692
/* -----------------------------------
691
693
GLOBALS & DATA
692
694
----------------------------------- */
@@ -1299,6 +1301,7 @@ <h3>Import Options</h3>
1299
1301
1300
1302
// 3) toggle only that blob
1301
1303
chains [ bestIndex ] . frozen = ! chains [ bestIndex ] . frozen ;
1304
+ chains [ bestIndex ] . alpha = chains [ bestIndex ] . frozen ? 0.3 : 1.0 ;
1302
1305
}
1303
1306
return ;
1304
1307
}
@@ -1862,6 +1865,10 @@ <h3>Import Options</h3>
1862
1865
gl . uniform4fv ( lineColorLoc , chainObj . color ) ; // colour doesn’t matter
1863
1866
gl . drawArrays ( gl . TRIANGLES , 0 , tris . length / 2 ) ;
1864
1867
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
+
1865
1872
// 2) draw one big quad wherever stencil==1 (the filled blob)
1866
1873
gl . colorMask ( true , true , true , true ) ;
1867
1874
gl . stencilFunc ( gl . EQUAL , 1 , 1 ) ;
0 commit comments