more purdy

This commit is contained in:
Adam 2023-01-17 05:08:05 -05:00
parent ec3a72cf07
commit 2037ae18e8
7 changed files with 80 additions and 56 deletions

View file

@ -2,6 +2,8 @@
margin: auto; margin: auto;
width: 350px; width: 350px;
outline-style: solid; outline-style: solid;
outline-color: #DA9475; outline-color: #B87253;
background-color: #111; background:
linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,.5)),
url('media/noise.svg');
} }

View file

@ -3,12 +3,56 @@ import './Machine.css';
import Rotorbox from './components/Rotorbox.js'; import Rotorbox from './components/Rotorbox.js';
import Lightbox from './components/Lightbox.js'; import Lightbox from './components/Lightbox.js';
import Keyboard from './components/Keyboard.js'; import Keyboard from './components/Keyboard.js';
import clicksound from './media/mixkit-hard-click-1118.wav';
class Machine extends Component { class Machine extends Component {
constructor() {
super();
this.state = {
rotor0: 11,
rotor1: 8,
rotor2: 6,
rotor3: 11,
rotor4: 23
};
}
tick() {
const audio = new Audio(clicksound);
audio.loop = false;
audio.playbackRate = 3.0;
audio.play();
this.setState(state => ({
rotor4: state.rotor4 +1
}));
if (this.state.rotor4 === 25) {
this.setState(state => ({
rotor3: state.rotor3 +1,
rotor4: 0
}));
}
if (this.state.rotor3 === 25) {
this.setState(state => ({
rotor2: state.rotor2 +1,
rotor3: 0
}));
}
if (this.state.rotor2 === 25) {
this.setState(state => ({
rotor1: state.rotor1 +1,
rotor2: 0
}));
}
if (this.state.rotor1 === 25) {
this.setState(state => ({
rotor0: state.rotor0 +1,
rotor1: 0
}));
}
}
render() { render() {
return ( return (
<div className='Machine'> <div className='Machine' onClick={() => this.tick()}>
<Rotorbox/> <Rotorbox state={this.state}/>
<hr/> <hr/>
<Lightbox/> <Lightbox/>
<hr/> <hr/>

View file

@ -6,6 +6,7 @@
} }
.Keyboard { .Keyboard {
margin: auto; margin: auto;
opacity: 0.9;
} }
.Key { .Key {
text-align: center; text-align: center;
@ -16,5 +17,6 @@
background-color: var(--keyback); background-color: var(--keyback);
color: var(--keytext); color: var(--keytext);
outline-style: solid; outline-style: solid;
outline-color: #555; outline-width: 1px;
outline-color: #DDD;
} }

View file

@ -6,6 +6,7 @@
} }
.Lightbox { .Lightbox {
margin: auto; margin: auto;
opacity: 0.9;
} }
.row { .row {
display: flex; display: flex;
@ -20,4 +21,7 @@
text-align: center; text-align: center;
background-color: var(--bulbdim); background-color: var(--bulbdim);
color: var(--textdim); color: var(--textdim);
border: solid;
border-width: 1px;
border-color: #000;
} }

View file

@ -1,4 +1,5 @@
.Rotorbox { .Rotorbox {
padding-left: 20%; padding-left: 10%;
display: flex; display: flex;
opacity: 0.9;
} }

View file

@ -1,60 +1,16 @@
import React from 'react'; import React from 'react';
import Rotor from './Rotor.js'; import Rotor from './Rotor.js';
import './Rotorbox.css'; import './Rotorbox.css';
import clicksound from '../media/mixkit-hard-click-1118.wav';
class Rotorbox extends React.Component { class Rotorbox extends React.Component {
constructor() {
super();
this.state = {
rotor0: 11,
rotor1: 8,
rotor2: 6,
rotor3: 11,
rotor4: 23
};
}
tick() {
const audio = new Audio(clicksound);
audio.loop = false;
audio.playbackRate = 3.0;
audio.play();
this.setState(state => ({
rotor4: state.rotor4 +1
}));
if (this.state.rotor4 === 25) {
this.setState(state => ({
rotor3: state.rotor3 +1,
rotor4: 0
}));
}
if (this.state.rotor3 === 25) {
this.setState(state => ({
rotor2: state.rotor2 +1,
rotor3: 0
}));
}
if (this.state.rotor2 === 25) {
this.setState(state => ({
rotor1: state.rotor1 +1,
rotor2: 0
}));
}
if (this.state.rotor1 === 25) {
this.setState(state => ({
rotor0: state.rotor0 +1,
rotor1: 0
}));
}
}
render() { render() {
return ( return (
<div className='Rotorbox' onClick={() => this.tick()}> <div className='Rotorbox'>
<Rotor pos={this.state.rotor0}/> <Rotor pos={this.props.state.rotor0}/>
<Rotor pos={this.state.rotor1}/> <Rotor pos={this.props.state.rotor1}/>
<Rotor pos={this.state.rotor2}/> <Rotor pos={this.props.state.rotor2}/>
<Rotor pos={this.state.rotor3}/> <Rotor pos={this.props.state.rotor3}/>
<Rotor pos={this.state.rotor4}/> <Rotor pos={this.props.state.rotor4}/>
</div> </div>
); );
} }

15
src/media/noise.svg Normal file
View file

@ -0,0 +1,15 @@
<svg
xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'
width='300' height='300'>
<filter id='n' x='0' y='0'>
<feTurbulence
type='fractalNoise'
baseFrequency='0.75'
stitchTiles='stitch'/>
</filter>
<rect width='300' height='300' fill='#000'/>
<rect width='300' height='300' filter='url(#n)' opacity='0.80'/>
</svg>

After

Width:  |  Height:  |  Size: 448 B