initial commit uwu

main
anna 3 months ago
commit ccd31710ae
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

2
.gitignore vendored

@ -0,0 +1,2 @@
node_modules/
dist/bundle.js

30
dist/index.html vendored

@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wfc</title>
<style>
* {
box-sizing: border-box;
}
html, body {
margin: 0;
overflow: hidden;
background-color: black;
}
#render {
position: absolute;
top: 0;
left: 0;
background-color: black;
}
</style>
</head>
<body>
<canvas id="render"></canvas>
<script type="text/javascript" src="bundle.js"></script>
</body>
</html>

6209
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,29 @@
{
"name": "wfcjs",
"version": "0.1.0",
"description": "wave function collapse in typescript",
"private": true,
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "NODE_ENV=development webpack-dev-server --open"
},
"repository": {
"type": "git",
"url": "https://git.bsd.gay/fef/wfcjs.git"
},
"keywords": [
"grahics",
"wfc"
],
"author": "fef",
"license": "BSD-2-Clause",
"devDependencies": {
"ts-loader": "^9.4.1",
"typescript": "^4.8.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0"
}
}

@ -0,0 +1,38 @@
export class App {
private canvas: HTMLCanvasElement;
private lastTime: DOMHighResTimeStamp = 0;
private isRunning: boolean = false;
public constructor(canvas: HTMLCanvasElement) {
this.canvas = canvas;
this.updateSize(window.innerWidth, window.innerHeight);
document.onresize = () => this.updateSize(window.innerWidth, window.innerHeight);
}
public run() {
this.isRunning = true;
this.draw(this.lastTime);
}
public stop() {
this.isRunning = false;
}
private draw(time: DOMHighResTimeStamp) {
// TODO: actually draw stuff
this.lastTime = time;
if (this.isRunning) {
window.requestAnimationFrame(t => this.draw(t));
}
}
private updateSize(width: number, height: number) {
this.canvas.width = width;
this.canvas.height = height;
}
}
const app = new App(document.getElementById("render") as HTMLCanvasElement);
app.run();

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"noImplicitAny": true,
"removeComments": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"resolveJsonModule": true,
},
"files": [
"src/app.ts"
]
}

@ -0,0 +1,28 @@
const path = require("path");
module.exports = {
entry: "./src/app.ts",
mode: process.env.NODE_ENV || "production",
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
},
],
},
devtool: "inline-source-map",
devServer: {
static: "./dist",
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
resolve: {
extensions: [ ".ts", ".js", ".json" ],
},
experiments: {
topLevelAwait: true,
},
};
Loading…
Cancel
Save