added bootstrap

This commit is contained in:
andy 2021-06-22 15:28:31 +01:00
parent b94ff668cc
commit de8ef49de3
4 changed files with 102 additions and 32 deletions

View File

@ -1,6 +1,8 @@
Game of Life Game of Life
=============== ===============
![gof-ci](https://github.com/sarsoo/game-of-life/actions/workflows/test.yml/badge.svg)
## [Try it Out!](https://sarsoo.github.io/game-of-life/) ## [Try it Out!](https://sarsoo.github.io/game-of-life/)
WASM-based game of life following the [Rust WASM book](https://rustwasm.github.io/docs/book/introduction.html) tutorial. WASM-based game of life following the [Rust WASM book](https://rustwasm.github.io/docs/book/introduction.html) tutorial.

View File

@ -1,38 +1,106 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="utf-8"> <meta charset="utf-8">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>game of life</title> <title>game of life</title>
<style> <style>
body { body {
position: absolute; /* position: absolute; */
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
}
background: #f0f0f0;
}
h1 {
font-family: monospace;
}
</style> </style>
</head> </head>
<body>
<input type="range" id="frameRate" name="frameRate" min="1" max="500" value="50"> <body>
<label for="frameRate" id="frameRate-label">Frame Interval: 50</label> <div class="card container-xs text-center p-4 m-3">
<input type="range" id="randThreshold" name="randThreshold" min="0" max="100" value="50"> <div class="card-header">
<label for="randThreshold" id="randThreshold-label">Rand Threshold: 50</label> <h1>Game of Life</h1>
<input type="number" id="width" name="width" min="1" max="1000" value="100"> </div>
<label for="width">width</label> <div class="card-body">
<input type="number" id="height" name="height" min="1" max="1000" value="100"> <div class="row p-3">
<label for="height">height</label> <div class="col-sm-6">
<input type="range"
id="frameRate"
name="frameRate"
min="1" max="500" value="50"
class="form-range">
<label for="frameRate"
id="frameRate-label"
class="form-label">Frame Interval: 50</label>
</div>
<div class="col-sm-6">
<input type="range"
id="randThreshold"
name="randThreshold"
min="0" max="100" value="50"
class="form-range">
<label for="randThreshold"
id="randThreshold-label"
class="form-label">Rand Threshold: 50</label>
</div>
</div>
<div class="row p-3">
<div class="col-sm-6">
<input type="number"
id="width"
name="width"
min="1" max="1000" value="100"
class="form-control">
<label for="width">width</label>
</div>
<div class="col-sm-6">
<input type="number"
id="height"
name="height"
min="1" max="1000" value="100"
class="form-control">
<label for="height">height</label>
</div>
</div>
<div class="row p-3 align-items-center">
<div class="col-sm-6">
<input type="checkbox"
id="play-check"
name="play-check"
class="form-check-input">
<label for="play-check">Play</label>
</div>
<div class="col-sm-6">
<div class="row p-1">
<button id="step" class="btn btn-primary">Step</button>
</div>
<div class="row p-1">
<button id="reset" class="btn btn-primary">Reset</button>
</div>
</div>
</div>
</div>
</div>
<!-- <pre id="game-of-life-canvas"></pre> --> <!-- <pre id="game-of-life-canvas"></pre> -->
<canvas id="game-of-life-canvas"></canvas> <canvas id="game-of-life-canvas" class="pb-2"></canvas>
<input type="checkbox" id="play-check" name="play-check">
<label for="play-check">Play</label>
<button id="step">Step</button>
<button id="reset">Reset</button>
<div id="fps"></div>
<script src="./bootstrap.js"></script> <script src="./bootstrap.js"></script>
</body>
<img src="https://storage.googleapis.com/sarsooxyzstatic/andy.png" class=" pb-2" style="width: 150px" />
<!-- <div id="fps"></div> -->
</body>
</html> </html>

View File

@ -72,7 +72,7 @@ const drawCells = () => {
}; };
const renderSingle = () => { const renderSingle = () => {
fps.render(); //new // fps.render(); //new
universe.tick(); universe.tick();
drawGrid(); drawGrid();

View File

@ -1,7 +1,7 @@
{ {
"name": "game-of-life-web", "name": "game-of-life-web",
"version": "0.1.0", "version": "0.1.0",
"description": "basic wasm-based game-of-life", "description": "Rust wasm-based game-of-life",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "webpack --config webpack.config.js", "build": "webpack --config webpack.config.js",