2022-01-09 11:47:18 +01:00
|
|
|
<template>
|
|
|
|
<MenuRow row-title="Elementary Cellular Automata">
|
|
|
|
<div class="form-field">
|
|
|
|
<label>Rules</label>
|
|
|
|
</div>
|
|
|
|
<form>
|
2022-01-10 11:13:44 +01:00
|
|
|
<div
|
|
|
|
v-for="rule in rules"
|
|
|
|
:key="rule"
|
|
|
|
class="form-field"
|
|
|
|
>
|
|
|
|
<label>{{ rule }}
|
2022-01-09 11:47:18 +01:00
|
|
|
<input
|
2022-01-10 11:13:44 +01:00
|
|
|
:value="getRule(rule)"
|
2022-01-09 11:47:18 +01:00
|
|
|
type="checkbox"
|
2022-01-10 11:13:44 +01:00
|
|
|
:name="rule"
|
|
|
|
:checked="getRule(rule) == 1"
|
|
|
|
@input="update1dRules"
|
2022-01-09 11:47:18 +01:00
|
|
|
>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<div class="form-field">
|
|
|
|
<input
|
|
|
|
type="button"
|
|
|
|
name="start"
|
|
|
|
value="start"
|
|
|
|
@click="draw1d"
|
|
|
|
>
|
2022-01-10 11:13:44 +01:00
|
|
|
<!-- <input -->
|
|
|
|
<!-- type="button" -->
|
|
|
|
<!-- name="stop" -->
|
|
|
|
<!-- class="stop" -->
|
|
|
|
<!-- value="stop" -->
|
|
|
|
<!-- > -->
|
2022-01-09 11:47:18 +01:00
|
|
|
<input
|
|
|
|
type="button"
|
|
|
|
name="reset"
|
|
|
|
class="reset"
|
|
|
|
value="reset"
|
2022-01-10 11:13:44 +01:00
|
|
|
@click="reset()"
|
2022-01-09 11:47:18 +01:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</MenuRow>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import MenuRow from './MenuRow.vue'
|
|
|
|
export default {
|
|
|
|
name: 'MenuElementaryCA',
|
|
|
|
components: {
|
|
|
|
MenuRow
|
|
|
|
},
|
2022-01-10 11:13:44 +01:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
rules: ["111", "110", "101", "100", "011", "010", "001", "000"]
|
|
|
|
}
|
|
|
|
},
|
2022-01-09 11:47:18 +01:00
|
|
|
methods: {
|
|
|
|
update1dRules(event) {
|
|
|
|
const elem = event.target
|
2022-01-10 11:13:44 +01:00
|
|
|
const value = elem.checked ? 1 : 0
|
2022-01-09 11:47:18 +01:00
|
|
|
const data = { 'rule' : elem.name, 'value' : value}
|
|
|
|
this.$store.commit('update1dRules', data)
|
|
|
|
},
|
|
|
|
draw1d() {
|
|
|
|
this.$root.$emit('draw1d')
|
|
|
|
},
|
2022-01-10 11:13:44 +01:00
|
|
|
getRule(id) {
|
|
|
|
const rules = this.$store.state.rules1d
|
|
|
|
return rules[id]
|
|
|
|
},
|
|
|
|
reset() {
|
|
|
|
this.$root.$emit('reset')
|
|
|
|
},
|
2022-01-09 11:47:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|