From 889c9b59ac9fa6208b92e4fce5a533a16abd3131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Fri, 25 Mar 2022 13:17:57 +0100 Subject: [PATCH] [ui] brightness/contrast toolbar in ImageViewer --- .../display/blobs/ImageViewer.svelte | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/webui/src/components/display/blobs/ImageViewer.svelte b/webui/src/components/display/blobs/ImageViewer.svelte index c5b466d..af62cb8 100644 --- a/webui/src/components/display/blobs/ImageViewer.svelte +++ b/webui/src/components/display/blobs/ImageViewer.svelte @@ -3,6 +3,7 @@ import { deleteEntry, fetchEntity, putEntry } from "../../../lib/api"; import { useEntity } from "../../../lib/entity"; + import IconButton from "../../utils/IconButton.svelte"; import Spinner from "../../utils/Spinner.svelte"; import UpObject from "../UpObject.svelte"; @@ -184,24 +185,54 @@ document.exitFullscreen(); } } + + let brightnesses = [0.5, 0.75, 1, 1.25, 1.5, 2, 2.5]; + let brightnessIdx = 2; + function cycleBrightness() { + brightnessIdx++; + brightnessIdx = brightnessIdx % brightnesses.length; + } + + let contrasts = [0.5, 0.75, 1, 1.25, 1.5]; + let contrastsIdx = 2; + function cycleContrast() { + contrastsIdx++; + contrastsIdx = contrastsIdx % contrasts.length; + } + + $: { + if (imageEl) { + const brightness = brightnesses[brightnessIdx]; + const contrast = contrasts[contrastsIdx]; + imageEl.style.filter = `brightness(${brightness}) contrast(${contrast})`; + } + } -
+
{#if !imageLoaded} {/if} - {address} + {#if imageLoaded} +
+ + +
+ {/if} +
+ {address} +