File size: 1,491 Bytes
8766bc5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | <script lang="ts">
import { IconButton } from "@gradio/atoms";
import { Brush, Color } from "@gradio/icons";
let show_size = false;
let show_col = false;
export let brush_radius = 20;
export let brush_color = "#000";
export let container_height: number;
export let img_width: number;
export let img_height: number;
export let mode: "mask" | "other" = "other";
$: width = container_height * (img_width / img_height);
</script>
<div class="wrap">
<span class="brush">
<IconButton
Icon={Brush}
label="Use brush"
on:click={() => (show_size = !show_size)}
/>
{#if show_size}
<input
aria-label="Brush radius"
bind:value={brush_radius}
type="range"
min={0.5 * (img_width / width)}
max={75 * (img_width / width)}
/>
{/if}
</span>
{#if mode !== "mask"}
<span class="col">
<IconButton
Icon={Color}
label="Select brush color"
on:click={() => (show_col = !show_col)}
/>
{#if show_col}
<input aria-label="Brush color" bind:value={brush_color} type="color" />
{/if}
</span>
{/if}
</div>
<style>
.wrap {
display: flex;
position: absolute;
top: var(--size-10);
right: var(--size-2);
flex-direction: column;
justify-content: flex-end;
gap: var(--spacing-sm);
z-index: var(--layer-5);
}
.brush {
top: 0;
right: 0;
}
.brush input {
position: absolute;
top: 3px;
right: calc(100% + 5px);
}
.col input {
position: absolute;
right: calc(100% + 5px);
bottom: -4px;
}
</style>
|