forked from external-repos/squoosh
Easter egg (#123)
* lol zx quant * Adding ZX option * Improving colour selection so we don't end up with the same colour twice. Also fixing a bug with the colour conflict resolution. * Putting it behind a konami code * Better comments * Adding comment * Removing unnecessary malloc.
This commit is contained in:
@@ -1,29 +1,55 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { bind, inputFieldValueAsNumber } from '../../lib/util';
|
||||
import { bind, inputFieldValueAsNumber, konami } from '../../lib/util';
|
||||
import { QuantizeOptions } from './quantizer';
|
||||
|
||||
const konamiPromise = konami();
|
||||
|
||||
interface Props {
|
||||
options: QuantizeOptions;
|
||||
onChange(newOptions: QuantizeOptions): void;
|
||||
}
|
||||
|
||||
export default class QuantizerOptions extends Component<Props, {}> {
|
||||
interface State {
|
||||
extendedSettings: boolean;
|
||||
}
|
||||
|
||||
export default class QuantizerOptions extends Component<Props, State> {
|
||||
state: State = { extendedSettings: false };
|
||||
|
||||
componentDidMount() {
|
||||
konamiPromise.then(() => {
|
||||
this.setState({ extendedSettings: true });
|
||||
});
|
||||
}
|
||||
|
||||
@bind
|
||||
onChange(event: Event) {
|
||||
const form = (event.currentTarget as HTMLInputElement).closest('form') as HTMLFormElement;
|
||||
|
||||
const options: QuantizeOptions = {
|
||||
zx: inputFieldValueAsNumber(form.zx),
|
||||
maxNumColors: inputFieldValueAsNumber(form.maxNumColors),
|
||||
dither: inputFieldValueAsNumber(form.dither),
|
||||
};
|
||||
this.props.onChange(options);
|
||||
}
|
||||
|
||||
render({ options }: Props) {
|
||||
render({ options }: Props, { extendedSettings }: State) {
|
||||
return (
|
||||
<form>
|
||||
<label>
|
||||
Pallette Colors:
|
||||
<label style={{ display: extendedSettings ? '' : 'none' }}>
|
||||
Type:
|
||||
<select
|
||||
name="zx"
|
||||
value={'' + options.zx}
|
||||
onChange={this.onChange}
|
||||
>
|
||||
<option value="0">Standard</option>
|
||||
<option value="1">ZX</option>
|
||||
</select>
|
||||
</label>
|
||||
<label style={{ display: options.zx ? 'none' : '' }}>
|
||||
Palette Colors:
|
||||
<input
|
||||
name="maxNumColors"
|
||||
type="range"
|
||||
|
||||
Reference in New Issue
Block a user