diff --git a/src/components/Canvas.vue b/src/components/Canvas.vue index 88c10d4..5e4f74a 100644 --- a/src/components/Canvas.vue +++ b/src/components/Canvas.vue @@ -23,7 +23,7 @@ export default { computed: { ...mapGetters({ cellProperties: 'getCellProperties', - rules: 'getRuleSet1d', + rules: 'get1dRules', drawing: 'isDrawing', canvasWidth: 'getCanvasWidth', canvasHeight: 'getCanvasHeight', diff --git a/src/components/MenuElementaryCA.vue b/src/components/MenuElementaryCA.vue index 538fac7..56423c7 100644 --- a/src/components/MenuElementaryCA.vue +++ b/src/components/MenuElementaryCA.vue @@ -11,7 +11,7 @@ > @@ -21,18 +21,41 @@
+
+ +
+
+ copy rules +
-
@@ -44,12 +67,6 @@ value="start" @click="draw1d" > - - - - - - { + return this.rules[index] + }).join("_") + ".json" + }, }, methods: { + copy1dRules(){ + const rules = JSON.stringify(this.rules) + navigator.clipboard.writeText(rules) + }, isCurrentPreset(event) { - console.log(elem.value) const elem = event.target return this.initialState === elem.value }, - update1dRules(event) { + update1dSingleRule(event) { const elem = event.target const value = elem.checked ? 1 : 0 const data = { 'rule' : elem.name, 'value' : value} - this.$store.commit('update1dRules', data) + this.$store.commit('update1dSingleRule', data) + }, + update1dRules(event) { + const elem = event.target + const name = elem.value + const rules = this.presetRules[name] + console.log(rules) + Object.keys(rules).map((index) => { + const data = { 'rule' : index, 'value' : rules[index]} + console.log(rules[index]) + this.$store.commit('update1dSingleRule', data) + }) }, updateInitial1dState(event) { const elem = event.target @@ -111,13 +155,17 @@ export default { this.$root.$store.state.drawing = 1 this.$root.$emit('draw1d') }, - getRule(id) { - const rules = this.$store.state.rules1d - return rules[id] - }, reset() { this.$root.$emit('reset') }, } } + diff --git a/src/store/index.js b/src/store/index.js index 37145f1..5a7069e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -27,9 +27,12 @@ export default new Vuex.Store({ initial1dState: "onecell" }, mutations: { - update1dRules(state, data) { + update1dSingleRule(state, data) { state.rules1d[data.rule] = data.value }, + update1dRules(state, data) { + state.rules1d = data + }, setCellProperties(state, data) { state.cellProperties[data.name] = data.value }, @@ -53,7 +56,7 @@ export default new Vuex.Store({ getCellProperties(state) { return state.cellProperties }, - getRuleSet1d(state) { + get1dRules(state) { return state.rules1d }, getRule1d(state) {