gif color count slider (2-256) and dithering control in editing screen, both wired through export/preview pipeline
This commit is contained in:
+38
-2
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte"
|
||||
import { api, convertFileSrc, formatBytes, type Config, type Format, type GifBudgetMode, type RecordedClip, type ExportResult, type CaptureRect } from "./api"
|
||||
import { api, convertFileSrc, formatBytes, type Config, type Format, type GifBudgetMode, type GifDither, type RecordedClip, type ExportResult, type CaptureRect } from "./api"
|
||||
import { save } from "@tauri-apps/plugin-dialog"
|
||||
import { emit } from "@tauri-apps/api/event"
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
let pathOverridden: boolean = $state(false)
|
||||
|
||||
let gifBudgetMode: GifBudgetMode = $state("balanced")
|
||||
let gifDither: GifDither = $state("floyd_steinberg")
|
||||
let gifColors: number = $state(256)
|
||||
|
||||
// Post-record crop
|
||||
let cropEnabled: boolean = $state(false)
|
||||
@@ -114,6 +116,7 @@
|
||||
format = config.export.default_format
|
||||
fps = config.capture.default_fps
|
||||
keepAudio = config.capture.capture_audio
|
||||
gifDither = config.export.gif_dither
|
||||
|
||||
unlistenHotkey = await api.onHotkey((kind) => {
|
||||
if (kind === "start" && phase === "idle") void startRec()
|
||||
@@ -205,7 +208,7 @@
|
||||
if (!clip) return
|
||||
previewLoading = true
|
||||
try {
|
||||
previewPath = await api.renderPreview(format, fps, Math.round(targetMB * 1_048_576), format === "gif" ? gifBudgetMode : undefined)
|
||||
previewPath = await api.renderPreview(format, fps, Math.round(targetMB * 1_048_576), format === "gif" ? gifBudgetMode : undefined, format === "gif" ? gifDither : undefined, format === "gif" ? gifColors : undefined)
|
||||
previewCacheBust = Date.now()
|
||||
} catch { previewPath = null }
|
||||
finally { previewLoading = false }
|
||||
@@ -249,6 +252,8 @@
|
||||
output_path: outputPath.trim() || null,
|
||||
crop,
|
||||
gif_budget_mode: format === "gif" ? gifBudgetMode : undefined,
|
||||
gif_dither: format === "gif" ? gifDither : undefined,
|
||||
gif_colors: format === "gif" ? gifColors : undefined,
|
||||
})
|
||||
exportResult = result; phase = "done"
|
||||
} catch (e) { errMsg = String(e); phase = "editing" }
|
||||
@@ -652,6 +657,37 @@
|
||||
"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={gifColors}
|
||||
onchange={refreshPreview}
|
||||
/>
|
||||
<span class="mono" style="min-width:32px;text-align:right">{gifColors}</span>
|
||||
</div>
|
||||
<p class="estimate">{gifColors <= 32 ? "Low - small file, posterized" : gifColors <= 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={gifDither === d}
|
||||
onclick={() => { gifDither = d; refreshPreview() }}
|
||||
>{d === "floyd_steinberg" ? "Floyd-Steinberg" : d === "bayer" ? "Bayer" : "None"}</button>
|
||||
{/each}
|
||||
</div>
|
||||
<p class="estimate">{gifDither === "floyd_steinberg" ? "Smooth gradients, slightly larger" : gifDither === "bayer" ? "Patterned, smaller file" : "No dithering, smallest file"}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- FPS + Audio -->
|
||||
|
||||
Reference in New Issue
Block a user