105 lines
2.1 KiB
JavaScript
105 lines
2.1 KiB
JavaScript
import Vue from "vue";
|
|
import Vuex from "vuex";
|
|
|
|
Vue.use(Vuex);
|
|
|
|
export default new Vuex.Store({
|
|
state: {
|
|
drawing: 0,
|
|
rules1d: {
|
|
111: 0,
|
|
110: 1,
|
|
101: 0,
|
|
100: 0,
|
|
"011": 1,
|
|
"010": 0,
|
|
"001": 0,
|
|
"000": 1,
|
|
},
|
|
cellProperties: {
|
|
size: 3,
|
|
liveColor: "#000000",
|
|
deadColor: "#F5F5F5",
|
|
},
|
|
canvasWidth: 0,
|
|
canvasHeight: 0,
|
|
refreshRate: 300,
|
|
initial1dState: "onecell",
|
|
activeMenu: "",
|
|
drawingDirection: "y",
|
|
lastBoard: {},
|
|
},
|
|
mutations: {
|
|
update1dSingleRule(state, data) {
|
|
state.rules1d[data.rule] = data.value;
|
|
},
|
|
update1dRules(state, data) {
|
|
state.rules1d = data;
|
|
},
|
|
setCellProperties(state, data) {
|
|
state.cellProperties[data.name] = data.value;
|
|
},
|
|
setDrawingStatus(state, data) {
|
|
state.drawing = data;
|
|
},
|
|
setCanvasWidth(state, data) {
|
|
state.canvasWidth = data;
|
|
},
|
|
setCanvasHeight(state, data) {
|
|
state.canvasHeight = data;
|
|
},
|
|
setRefreshRate(state, data) {
|
|
state.refreshRate = data;
|
|
},
|
|
setInitial1dState(state, data) {
|
|
state.initial1dState = data;
|
|
},
|
|
setActiveMenu(state, data) {
|
|
state.activeMenu = data;
|
|
},
|
|
setDrawingDirection(state, data) {
|
|
state.drawingDirection = data;
|
|
},
|
|
setLastBoard(state, data) {
|
|
state.lastBoard = data;
|
|
},
|
|
},
|
|
getters: {
|
|
getCellProperties(state) {
|
|
return state.cellProperties;
|
|
},
|
|
get1dRules(state) {
|
|
return state.rules1d;
|
|
},
|
|
getRule1d(state) {
|
|
return (rule) => state.rules1d[rule];
|
|
},
|
|
isDrawing(state) {
|
|
return state.drawing;
|
|
},
|
|
getCanvasWidth(state) {
|
|
return state.canvasWidth;
|
|
},
|
|
getCanvasHeight(state) {
|
|
return state.canvasHeight;
|
|
},
|
|
getRefreshRate(state) {
|
|
return state.refreshRate;
|
|
},
|
|
getInitial1dState(state) {
|
|
return state.initial1dState;
|
|
},
|
|
getActiveMenu(state) {
|
|
return state.activeMenu;
|
|
},
|
|
getDrawingDirection(state) {
|
|
return state.drawingDirection;
|
|
},
|
|
getLastBoard(state) {
|
|
return state.lastBoard;
|
|
},
|
|
},
|
|
actions: {},
|
|
modules: {},
|
|
});
|