add scanlines

This commit is contained in:
Matt Walsh
2025-05-29 17:03:50 -05:00
parent 32aa43c5b1
commit 7efd2e8db7
12 changed files with 164 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

View File

@@ -38,6 +38,7 @@ const init = () => {
document.querySelector('#NavigateNext').addEventListener('click', btnNavigateNextClick);
document.querySelector('#NavigatePrevious').addEventListener('click', btnNavigatePreviousClick);
document.querySelector('#NavigatePlay').addEventListener('click', btnNavigatePlayClick);
document.querySelector('#ToggleScanlines').addEventListener('click', btnNavigateToggleScanlines);
document.querySelector(TOGGLE_FULL_SCREEN_SELECTOR).addEventListener('click', btnFullScreenClick);
const btnGetGps = document.querySelector(BNT_GET_GPS_SELECTOR);
btnGetGps.addEventListener('click', btnGetGpsClick);
@@ -344,6 +345,11 @@ const btnNavigatePlayClick = () => {
return false;
};
const btnNavigateToggleScanlines = () => {
settings.scanLines.value = !settings.scanLines.value;
return false;
};
// post a message to the iframe
const postMessage = (type, myMessage = {}) => {
navMessage({ type, message: myMessage });

View File

@@ -33,6 +33,12 @@ const init = () => {
[1.5, 'Very Slow'],
],
});
settings.scanLines = new Setting('scanLines', {
name: 'Scan Lines',
defaultValue: false,
changeAction: scanLineChange,
sticky: true,
});
settings.units = new Setting('units', {
name: 'Units',
type: 'select',
@@ -85,6 +91,18 @@ const kioskChange = (value) => {
}
};
const scanLineChange = (value) => {
const container = document.getElementById('container');
const navIcons = document.getElementById('ToggleScanlines');
if (value) {
container.classList.add('scanlines');
navIcons.classList.add('on');
} else {
container.classList.remove('scanlines');
navIcons.classList.remove('on');
}
};
const unitChange = () => {
// reload the data at the top level to refresh units
// after the initial load

View File

@@ -7,7 +7,7 @@ const blob = (url, params) => fetchAsync(url, 'blob', params);
const fetchAsync = async (_url, responseType, _params = {}) => {
// add user agent header to json request at api.weather.gov
const headers = {};
if (_url.match(/api\.weather\.gov/)) {
if (_url.toString().match(/api\.weather\.gov/)) {
headers['user-agent'] = 'Weatherstar 4000+; weatherstar@netbymatt.com';
}
// combine default and provided parameters

View File

@@ -189,7 +189,7 @@ class Setting {
break;
case 'checkbox':
default:
this.element.checked = newValue;
this.element.querySelector('input').checked = newValue;
}
this.storeToLocalStorage(this.myValue);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -458,6 +458,30 @@ body {
cursor: pointer;
}
#ToggleScanlines {
display: inline-block;
.on {
display: none;
}
.off {
display: inline-block;
}
&.on {
.on {
display: inline-block;
}
.off {
display: none;
}
}
}
.visible {
visibility: visible;
opacity: 1;

View File

@@ -13,4 +13,5 @@
@use 'almanac';
@use 'hazards';
@use 'media';
@use 'spc-outlook';
@use 'spc-outlook';
@use 'shared/scanlines';

View File

@@ -0,0 +1,106 @@
/* REGULAR SCANLINES SETTINGS */
// width of 1 scanline (min.: 1px)
$scan-width: 1px;
// emulates a damage-your-eyes bad pre-2000 CRT screen ♥ (true, false)
$scan-crt: false;
// frames-per-second (should be > 1), only applies if $scan-crt: true;
$scan-fps: 20;
// scanline-color (rgba)
$scan-color: rgba(#000, .3);
// set z-index on 8, like in ♥ 8-bits ♥, or…
// set z-index on 2147483648 or more to enable scanlines on Chrome fullscreen (doesn't work in Firefox or IE);
$scan-z-index: 2147483648;
/* MOVING SCANLINE SETTINGS */
// moving scanline (true, false)
$scan-moving-line: true;
// opacity of the moving scanline
$scan-opacity: .75;
/* MIXINS */
// apply CRT animation: @include scan-crt($scan-crt);
@mixin scan-crt($scan-crt) {
@if $scan-crt==true {
animation: scanlines 1s steps($scan-fps) infinite;
}
@else {
animation: none;
}
}
// apply CRT animation: @include scan-crt($scan-crt);
@mixin scan-moving($scan-moving-line) {
@if $scan-moving-line==true {
animation: scanline 6s linear infinite;
}
@else {
animation: none;
}
}
/* CSS .scanlines CLASS */
.scanlines {
position: relative;
overflow: hidden; // only to animate the unique scanline
&:before,
&:after {
display: block;
pointer-events: none;
content: '';
position: absolute;
}
// unique scanline travelling on the screen
&:before {
// position: absolute;
// bottom: 100%;
width: 100%;
height: $scan-width * 1;
z-index: $scan-z-index + 1;
background: $scan-color;
opacity: $scan-opacity;
// animation: scanline 6s linear infinite;
@include scan-moving($scan-moving-line);
}
// the scanlines, so!
&:after {
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $scan-z-index;
background: linear-gradient(to bottom,
transparent 50%,
$scan-color 51%);
background-size: 100% $scan-width*2;
@include scan-crt($scan-crt);
}
}
/* ANIMATE UNIQUE SCANLINE */
@keyframes scanline {
0% {
transform: translate3d(0, 200000%, 0);
// bottom: 0%; // to have a continuous scanline move, use this line (here in 0% step) instead of transform and write, in &:before, { position: absolute; bottom: 100%; }
}
}
@keyframes scanlines {
0% {
background-position: 0 50%;
// bottom: 0%; // to have a continuous scanline move, use this line (here in 0% step) instead of transform and write, in &:before, { position: absolute; bottom: 100%; }
}
}

View File

@@ -145,6 +145,10 @@
<img class="navButton off" src="images/nav/ic_volume_off_white_24dp_2x.png" title="Unmute" />
<img class="navButton on" src="images/nav/ic_volume_on_white_24dp_2x.png" title="Mute" />
</div>
<div id="ToggleScanlines">
<img class="navButton off" src="images/nav/ic_scanlines_off_white_24dp_2x.png" title="Scan lines on" />
<img class="navButton on" src="images/nav/ic_scanlines_on_white_24dp_2x.png" title="Scan lines off" />
</div>
<img id="ToggleFullScreen" class="navButton" src="images/nav/ic_fullscreen_white_24dp_2x.png" title="Enter Fullscreen" />
</div>
</div>