implement PPTY
This commit is contained in:
parent
a13032c76e
commit
d76ac04531
12 changed files with 499 additions and 118 deletions
|
|
@ -1,24 +1,59 @@
|
|||
import { Smc } from "./smc/smc.js"
|
||||
import { Smc, fetchShader } from "./smc/lib.js";
|
||||
import { PPTY } from "./ppty/lib.js";
|
||||
|
||||
main();
|
||||
|
||||
async function fetchShader(uri, delegate) {
|
||||
const res = await fetch(uri);
|
||||
if (res.ok)
|
||||
return await res.text();
|
||||
this.raiseError(
|
||||
SmcErr.FETCH_SHADER,
|
||||
`Failed to load shader source ${url}: ${res.status} ${res.json()}`);
|
||||
return ""
|
||||
function endBoot(root) {
|
||||
const style = getComputedStyle(root);
|
||||
const paddingLeft = parseFloat(style.paddingLeft);
|
||||
const paddingRight = parseFloat(style.paddingRight);
|
||||
const contentWidth = root.clientWidth - paddingLeft - paddingRight;
|
||||
const paddingTop = parseFloat(style.paddingTop);
|
||||
const paddingBottom = parseFloat(style.paddingBottom);
|
||||
const contentHeight = root.clientHeight - paddingTop - paddingBottom;
|
||||
|
||||
root.style.width = `${contentWidth}px`;
|
||||
root.style.height = `${contentHeight}px`;
|
||||
|
||||
const fade = root.animate(
|
||||
[{ opacity: 0 }],
|
||||
{
|
||||
duration: 400,
|
||||
delay: 3000,
|
||||
fill: "forwards",
|
||||
}
|
||||
);
|
||||
|
||||
fade.onfinish = () => root.remove();
|
||||
}
|
||||
|
||||
|
||||
function main() {
|
||||
const canvas = document.querySelector("#gl-canvas");
|
||||
const boot = document.querySelector("#boot-ppty")
|
||||
new PPTY(
|
||||
boot,
|
||||
[
|
||||
{
|
||||
cps: 12,
|
||||
promptDelay: 0.5,
|
||||
commandDelay: 0.7,
|
||||
outputDelay: 1,
|
||||
blinkTime: 0.6,
|
||||
},
|
||||
{
|
||||
cps: 10,
|
||||
promptDelay: 0,
|
||||
commandDelay: 1.5,
|
||||
outputDelay: 1.2,
|
||||
blinkTime: 0.6,
|
||||
}
|
||||
])
|
||||
.onfinish(endBoot)
|
||||
.run();
|
||||
|
||||
const canvas = document.querySelector("#bg-canvas");
|
||||
canvas.setAttribute('width', window.innerWidth);
|
||||
canvas.setAttribute('height', window.innerHeight);
|
||||
|
||||
|
||||
fetchShader("../shaders/segfault.glsl")
|
||||
.then(frag =>
|
||||
new Smc(canvas)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue