Added support for dark theme in loading screen.

This commit is contained in:
CalDescent
2022-03-08 22:29:37 +00:00
parent 4cb63100d3
commit 631a253bcc
3 changed files with 50 additions and 19 deletions

View File

@@ -128,6 +128,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<canvas id="c"></canvas>
<!-- partial -->
<script>
var theme = "%%THEME%%";
var w = c.width = window.innerWidth,
h = c.height = window.innerHeight,
ctx = c.getContext( '2d' ),
@@ -165,7 +167,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
baseRad = Math.PI * 2 / 6;
ctx.fillStyle = 'white';
if (theme === "dark") {
ctx.fillStyle = 'black';
}
else {
ctx.fillStyle = 'white';
}
ctx.fillRect( 0, 0, w, h );
function loop() {
@@ -176,9 +183,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
ctx.globalCompositeOperation = 'source-over';
ctx.shadowBlur = 0;
ctx.fillStyle = 'rgba(230,230,230,alp)'.replace( 'alp', opts.repaintAlpha );
ctx.fillRect( 0, 0, w, h );
ctx.globalCompositeOperation = 'darker';
if (theme === "dark") {
ctx.fillStyle = 'rgba(0,0,0,alp)'.replace('alp', opts.repaintAlpha);
ctx.fillRect( 0, 0, w, h );
ctx.globalCompositeOperation = 'lighter';
}
else {
ctx.fillStyle = 'rgba(230,230,230,alp)'.replace('alp', opts.repaintAlpha);
ctx.fillRect( 0, 0, w, h );
ctx.globalCompositeOperation = 'darker';
}
if( lines.length < opts.count && Math.random() < opts.spawnChance )
lines.push( new Line );