explorata/src/stores/index.js

102 lines
2.3 KiB
JavaScript
Raw Normal View History

2022-12-02 15:53:49 +01:00
import { defineStore } from "pinia";
export const globalStore = defineStore("globalStore", {
state: () => {
return {
2022-12-04 18:38:50 +01:00
ruleset1d: {
2022-12-02 15:53:49 +01:00
name: "rule 73",
rules: {
111: 0,
110: 1,
101: 0,
100: 0,
"011": 1,
"010": 0,
"001": 0,
"000": 1,
},
},
2022-12-15 16:18:57 +01:00
selected2dRules: {
id: "conway",
name: "Conway's Game of Life",
description: "The most popular 2d automata",
},
2022-12-02 15:53:49 +01:00
cellProperties: {
size: 3,
liveColor: "#000000",
deadColor: "#F5F5F5",
},
canvasWidth: 0,
canvasHeight: 0,
boardWidth: 0,
boardHeight: 0,
refreshRate: 300,
initial1dState: "onecell",
drawingDirection: "y",
2022-12-19 16:00:38 +01:00
lastBoard: null,
2022-12-02 15:53:49 +01:00
draw1d: false,
draw2d: false,
draw2dLast: false,
2022-12-06 17:41:32 +01:00
draw2dpicture: false,
2022-12-02 15:53:49 +01:00
reset: false,
canDraw: true,
2022-12-06 17:41:32 +01:00
picture: null,
mainMenu: false,
2022-12-10 10:45:34 +01:00
activeSubMenu: "",
2022-12-19 16:00:38 +01:00
loop: true,
2022-12-02 17:11:34 +01:00
};
2022-12-02 15:53:49 +01:00
},
actions: {
setBoardWidth() {
this.boardWidth = Math.floor(this.canvasWidth / this.cellProperties.size);
},
setBoardHeight() {
this.boardHeight = Math.floor(
this.canvasHeight / this.cellProperties.size
);
},
2022-12-02 17:10:21 +01:00
toggleDraw1d() {
2022-12-10 10:45:34 +01:00
this.setActiveSubMenu("");
this.setMainMenu(false);
2022-12-02 15:53:49 +01:00
this.draw1d = true;
},
2022-12-02 17:10:21 +01:00
toggleDraw2d() {
2022-12-10 10:45:34 +01:00
this.setActiveSubMenu("");
this.setMainMenu(false);
2022-12-04 18:47:20 +01:00
this.toggleStop();
2022-12-02 15:53:49 +01:00
this.canDraw = true;
this.draw2d = true;
},
2022-12-02 17:10:21 +01:00
toggleDraw2dLast() {
2022-12-10 10:45:34 +01:00
this.setActiveSubMenu("");
this.setMainMenu(false);
2022-12-04 18:47:20 +01:00
this.toggleStop();
2022-12-02 15:53:49 +01:00
this.canDraw = true;
this.draw2dLast = true;
},
2022-12-06 17:41:32 +01:00
toggle2dDrawFromPicture() {
this.toggleStop();
this.canDraw = true;
this.draw2dpicture = true;
},
2022-12-02 17:10:21 +01:00
toggleReset() {
this.toggleStop();
2022-12-02 15:53:49 +01:00
this.reset = true;
},
2022-12-02 17:10:21 +01:00
toggleStop() {
2022-12-02 15:53:49 +01:00
this.draw1d = false;
this.draw2d = false;
this.draw2dLast = false;
2022-12-06 17:41:32 +01:00
this.draw2dpicture = false;
2022-12-02 15:53:49 +01:00
this.canDraw = false;
},
2022-12-10 10:45:34 +01:00
setActiveSubMenu(data) {
if (this.activeSubMenu == data) this.activeSubMenu = "";
else this.activeSubMenu = data;
},
setMainMenu(data) {
this.mainMenu = data;
},
2022-12-02 15:53:49 +01:00
},
});