renderer module

This commit is contained in:
2022-12-23 16:41:03 +01:00
parent ce47479fa0
commit 34cf2b1f31
7 changed files with 108 additions and 82 deletions

View File

@ -1,5 +1,6 @@
import { defineStore } from "pinia";
import { Board } from "../modules/board.js";
import { Renderer } from "../modules/renderer.js";
export const globalStore = defineStore("globalStore", {
state: () => {
@ -22,9 +23,6 @@ export const globalStore = defineStore("globalStore", {
name: "Conway's Game of Life",
description: "The most popular 2d automata",
},
canvasWidth: 0,
canvasHeight: 0,
refreshRate: 300,
initial1dState: "onecell",
drawingDirection: "y",
board: new Board(),
@ -39,17 +37,18 @@ export const globalStore = defineStore("globalStore", {
activeSubMenu: "",
loop: false,
lastAction: "drawfromlast",
renderer: new Renderer(),
};
},
actions: {
setBoardWidth() {
this.board.width = Math.floor(
this.canvasWidth / this.board.cellProperties.size
this.renderer.width / this.board.cellProperties.size
);
},
setBoardHeight() {
this.board.height = Math.floor(
this.canvasHeight / this.board.cellProperties.size
this.renderer.height / this.board.cellProperties.size
);
},
setCellProperties(name, value) {