canvas size option, menu collapsed by default
This commit is contained in:
parent
74e9667c51
commit
010c34b5a9
@ -8,7 +8,26 @@
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<sidebar>
|
<sidebar>
|
||||||
<div class="menu-row">
|
<div class="menu-row">
|
||||||
<h2> Cell Properties</h2>
|
<h2>General Properties</h2>
|
||||||
|
<div class="menu-row-content">
|
||||||
|
<form>
|
||||||
|
<div class="form-field">
|
||||||
|
<label for="live">Canvas Resolution</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-field">
|
||||||
|
<input name="canvasWidth" type="number" id="canvasWidth" value="1280"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-field">
|
||||||
|
<input name="canvasHeight" type="number" id="canvasHeight" value="1024"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-field">
|
||||||
|
<input type="button" name="canvasRefresh" id="canvasRefresh" value="refresh"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="menu-row">
|
||||||
|
<h2>Cell Properties</h2>
|
||||||
<div class="menu-row-content">
|
<div class="menu-row-content">
|
||||||
<form>
|
<form>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
|
@ -14,10 +14,12 @@ const live = document.querySelector('#live');
|
|||||||
const cellSize = document.querySelector('#cellSize');
|
const cellSize = document.querySelector('#cellSize');
|
||||||
const startBtn = document.querySelector('#start');
|
const startBtn = document.querySelector('#start');
|
||||||
const startBtn2d = document.querySelector('#start2d');
|
const startBtn2d = document.querySelector('#start2d');
|
||||||
|
const canvasRefreshBtn = document.querySelector('#canvasRefresh');
|
||||||
const resetBtn = document.querySelectorAll('.reset');
|
const resetBtn = document.querySelectorAll('.reset');
|
||||||
const stopBtn = document.querySelectorAll('.stop');
|
const stopBtn = document.querySelectorAll('.stop');
|
||||||
// const loop = document.querySelector('#loop');
|
// const loop = document.querySelector('#loop');
|
||||||
const menuRow = document.querySelectorAll('.menu-row');
|
const menuRow = document.querySelectorAll('.menu-row');
|
||||||
|
const menuRowContent = document.querySelectorAll('.menu-row-content');
|
||||||
|
|
||||||
function drawCanvas(board, props) {
|
function drawCanvas(board, props) {
|
||||||
board.map((row, y) => {
|
board.map((row, y) => {
|
||||||
@ -136,6 +138,13 @@ stopBtn.forEach((elem) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
canvasRefreshBtn.addEventListener('click', () => {
|
||||||
|
const width = document.querySelector('#canvasWidth').value;
|
||||||
|
const height = document.querySelector('#canvasWidth').value;
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
});
|
||||||
|
|
||||||
menuRow.forEach((elem) => {
|
menuRow.forEach((elem) => {
|
||||||
elem.querySelector('h2').addEventListener('click', async (e) => {
|
elem.querySelector('h2').addEventListener('click', async (e) => {
|
||||||
const parent = e.currentTarget.parentNode;
|
const parent = e.currentTarget.parentNode;
|
||||||
@ -147,8 +156,11 @@ menuRow.forEach((elem) => {
|
|||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
resizeCanvas();
|
resizeCanvas();
|
||||||
|
menuRowContent.forEach((elem) => {
|
||||||
|
elem.style.setProperty('display', 'none');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
resizeCanvas();
|
// resizeCanvas();
|
||||||
});
|
});
|
||||||
|
@ -32,8 +32,8 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sidebar {
|
sidebar {
|
||||||
flex: auto;
|
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="button"] {
|
input[type="button"] {
|
||||||
|
Loading…
Reference in New Issue
Block a user