Skip to content

Commit

Permalink
Add crt demo
Browse files Browse the repository at this point in the history
  • Loading branch information
wusyong committed Aug 22, 2024
1 parent c9348d6 commit 89d6535
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions crt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!doctype html>
<html lang=en xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta charset=UTF-8>
<meta content="width=device-width,initial-scale=1" name=viewport>
<title>CRT Demo</title>
<style>
:root {
--primary-color: #ffa348;
--primary-color-alpha: #ffa34833;
--contrast-color: #000c
}

html, body {
height: 100%;
margin: 0;
padding: 0;
}

.crt {
height: 100%; /* Full viewport height */
width: 100%;
box-shadow: var(--edge-highlight), 0 0 0 0.0625rem var(--primary-color-alpha), 0 0.125rem 0.375rem 0.125rem var(--primary-color-alpha), 0 0.25rem 1.5rem 0.25rem var(--primary-color-alpha);
background: radial-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.85)), var(--primary-color);
}
.crt pre {
animation: flicker 0.25s alternate infinite;
margin: 0;
box-shadow: none;
background-color: transparent !important;
padding: 1rem 1rem;
color: var(--primary-color) !important;
text-shadow: var(--primary-color-alpha) 0 0 0.25rem, var(--primary-color) 0 0 0.75rem;
}
@keyframes flicker {
25% {
opacity: 0.95;
}
50% {
opacity: 0.85;
}
75% {
opacity: 1;
}
to {
opacity: 0.9;
}
}

.scanlines {
position: relative;
overflow: hidden;
}
.scanlines::before {
display: block;
position: absolute;
z-index: 1;
animation: scanlines 0.1s linear infinite;
inset: 0;
background-image: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25) 0.125rem, transparent 0.125rem, transparent 0.25rem);
pointer-events: none;
content: "";
}
@keyframes scanlines {
to {
background-position-y: 0.25rem;
}
}
.scanlines::after {
display: block;
position: absolute;
animation: scanline 5s linear infinite;
inset: 0;
background-image: linear-gradient(to bottom, transparent, var(--primary-color-alpha) 7rem, transparent 8rem);
background-size: auto 8rem;
background-repeat: no-repeat;
background-position-y: -8rem;
pointer-events: none;
content: "";
}
@keyframes scanline {
50%, to {
background-position-y: calc(100% + 8rem);
}
}

.cursor {
animation: cursor-blink 1s infinite;
}
@keyframes cursor-blink {
50% {
opacity: 0;
}
}
</style>
</head>

<body>
<div class="crt scanlines">
<pre>
<span>\ /\ _ _ ____ ____ ____ __ </span>
<span> ) ( ') / )( \( __)( _ \/ ___) / \ </span>
<span>( / ) \ \/ / ) _) ) /\___ \( O )</span>
<span> \(__)| \__/ (____)(__\_)(____/ \__/ </span>
</pre>
</div>
</body>
</html>

0 comments on commit 89d6535

Please sign in to comment.