-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
6,110 additions
and
218 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="author" value="Damon Zucconi" /> | ||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | ||
<meta | ||
name="viewport" | ||
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" | ||
/> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
|
||
<title>Interpolated Sequence</title> | ||
|
||
<link rel="stylesheet" type="text/css" href="./index.css" /> | ||
</head> | ||
<body> | ||
<div id="root" class="app"></div> | ||
|
||
<script src="./javascripts/index.ts"></script> | ||
|
||
<script> | ||
// TODO | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { FrameInterval } from "frame-interval"; | ||
import { configure } from "queryparams"; | ||
import { uid } from "./lib/uid"; | ||
import { rand } from "./lib/rand"; | ||
import { tag } from "./lib/dom"; | ||
|
||
const DOM = { | ||
app: document.getElementById("root"), | ||
}; | ||
|
||
const STATE: Record<string, number> = {}; | ||
|
||
const creator = | ||
(size: number) => | ||
(n: number, randomize: boolean): [string, CanvasRenderingContext2D] => { | ||
const id = `canvas_${uid()}`; | ||
|
||
const node = tag( | ||
"div", | ||
{ klass: "container" }, | ||
` <canvas id='${id}' width='${n}' height='${n}'></canvas> | ||
` | ||
); | ||
|
||
if (size) { | ||
node.style.width = `${size}px`; | ||
node.style.height = `${size}px`; | ||
} | ||
|
||
DOM.app.appendChild(node); | ||
|
||
DOM[id] = document.getElementById(id); | ||
STATE[id] = randomize ? rand(-1, 9) : -1; | ||
|
||
const ctx = (DOM[id] as HTMLCanvasElement).getContext("2d"); | ||
|
||
ctx.font = `${n}px 'Helvetica Neue', sans-serif`; | ||
ctx.fillStyle = "white"; | ||
ctx.textBaseline = "middle"; | ||
ctx.textAlign = "center"; | ||
|
||
return [id, ctx]; | ||
}; | ||
|
||
const update = ([id, ctx]: [string, CanvasRenderingContext2D]) => { | ||
if (STATE[id] === 9) STATE[id] = 0; | ||
|
||
STATE[id]++; | ||
|
||
ctx.clearRect(0, 0, DOM[id].width, DOM[id].height); | ||
ctx.fillText(String(STATE[id]), DOM[id].width / 2, DOM[id].height / 2); | ||
}; | ||
|
||
const { params } = configure({ | ||
fps: 60, | ||
amount: 10, | ||
offset: 1, | ||
step: 1, | ||
randomize: false, | ||
}); | ||
|
||
const create = creator( | ||
Math.min(window.innerWidth / params.amount, window.innerHeight) | ||
); | ||
|
||
const handles = Array(params.amount) | ||
.fill(undefined) | ||
.map((_, n) => { | ||
const step = n === 0 ? 1 : params.step; | ||
return create((n + params.offset) * step, params.randomize); | ||
}); | ||
|
||
const fi = new FrameInterval(params.fps, () => handles.forEach(update)); | ||
|
||
fi.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const rand = (min: number, max: number) => | ||
Math.floor(Math.random() * (max - min) + min); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const uid = () => | ||
("0000" + ((Math.random() * Math.pow(36, 4)) << 0).toString(36)).slice(-4); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.