129 lines
3.6 KiB
Svelte
129 lines
3.6 KiB
Svelte
<script lang="ts">
|
|
import type { GifBudgetMode, GifDither } from "./api"
|
|
|
|
let {
|
|
budgetMode = $bindable(),
|
|
dither = $bindable(),
|
|
colors = $bindable(),
|
|
onChange,
|
|
}: {
|
|
budgetMode: GifBudgetMode
|
|
dither: GifDither
|
|
colors: number
|
|
onChange: () => void
|
|
} = $props()
|
|
</script>
|
|
|
|
<div class="control-group">
|
|
<span class="section-title">Budget priority</span>
|
|
<div class="fmt-bar">
|
|
{#each (["resolution", "framerate", "balanced"] as const) as m}
|
|
<button
|
|
class="fmt-chip"
|
|
class:active={budgetMode === m}
|
|
onclick={() => { budgetMode = m; onChange() }}
|
|
>{m === "resolution" ? "Resolution" : m === "framerate" ? "Framerate" : "Balanced"}</button>
|
|
{/each}
|
|
</div>
|
|
<p class="estimate">
|
|
{budgetMode === "resolution" ? "Keeps resolution high, may reduce FPS" :
|
|
budgetMode === "framerate" ? "Keeps FPS high, may reduce resolution" :
|
|
"Balances resolution and FPS"}
|
|
</p>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<span class="section-title">Colors</span>
|
|
<div class="control-head">
|
|
<input
|
|
type="range"
|
|
class="styled-range"
|
|
min={2}
|
|
max={256}
|
|
step={1}
|
|
bind:value={colors}
|
|
onchange={onChange}
|
|
/>
|
|
<span class="mono" style="min-width:32px;text-align:right">{colors}</span>
|
|
</div>
|
|
<p class="estimate">{colors <= 32 ? "Low - small file, posterized" : colors <= 128 ? "Medium - balanced" : "High - full color"}</p>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<span class="section-title">Dithering</span>
|
|
<div class="fmt-bar">
|
|
{#each (["floyd_steinberg", "bayer", "none"] as const) as d}
|
|
<button
|
|
class="fmt-chip"
|
|
class:active={dither === d}
|
|
onclick={() => { dither = d; onChange() }}
|
|
>{d === "floyd_steinberg" ? "Floyd-Steinberg" : d === "bayer" ? "Bayer" : "None"}</button>
|
|
{/each}
|
|
</div>
|
|
<p class="estimate">{dither === "floyd_steinberg" ? "Smooth gradients, slightly larger" : dither === "bayer" ? "Patterned, smaller file" : "No dithering, smallest file"}</p>
|
|
</div>
|
|
|
|
<style>
|
|
.control-group { display: flex; flex-direction: column; gap: 8px; }
|
|
.control-head { display: flex; justify-content: space-between; align-items: center; }
|
|
.section-title {
|
|
font-size: 10px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.1em;
|
|
color: var(--text-3);
|
|
}
|
|
.estimate {
|
|
margin: 0;
|
|
font-size: 11px;
|
|
color: var(--text-3);
|
|
font-family: var(--mono);
|
|
}
|
|
|
|
.fmt-bar {
|
|
display: flex;
|
|
gap: 2px;
|
|
padding: 3px;
|
|
background: var(--bg-2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--r-sm);
|
|
width: fit-content;
|
|
}
|
|
.fmt-chip {
|
|
padding: 5px 14px;
|
|
background: transparent;
|
|
border: 1px solid transparent;
|
|
color: var(--text-3);
|
|
border-radius: var(--r-sm);
|
|
font-family: var(--mono);
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
letter-spacing: 0.04em;
|
|
cursor: pointer;
|
|
transition: all 80ms;
|
|
}
|
|
.fmt-chip:hover { color: var(--text-2); }
|
|
.fmt-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
|
|
|
|
.styled-range {
|
|
-webkit-appearance: none;
|
|
width: 100%;
|
|
height: 3px;
|
|
background: var(--bg-3);
|
|
border-radius: 2px;
|
|
outline: none;
|
|
cursor: pointer;
|
|
}
|
|
.styled-range::-webkit-slider-thumb {
|
|
-webkit-appearance: none;
|
|
width: 14px; height: 14px;
|
|
border-radius: 50%;
|
|
background: var(--accent);
|
|
border: 2px solid var(--bg);
|
|
cursor: pointer;
|
|
transition: transform 80ms;
|
|
}
|
|
.styled-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
|
|
.mono { font-family: var(--mono); }
|
|
</style>
|