Skip to content

Commit 9bc4c1b

Browse files
committed
feat: add scale.type original
1 parent 84dbbe2 commit 9bc4c1b

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/lib/components/ScaleOpts.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Scale type
1919
</label>
2020
<select id="scale-type" class="w-full" bind:value={scale.type}>
21+
<option value="original">Original scale</option>
2122
<option value="same">Same scale for x and y axis</option>
2223
<option value="different">Different scales for x and y axis</option>
2324
</select>
@@ -33,7 +34,7 @@
3334
<input id="scale-x" type="text" bind:value={scale.x} />
3435
</InputWithUnit>
3536
</FormField>
36-
{:else}
37+
{:else if scale.type === 'different'}
3738
<FormField>
3839
<label for="scale-x">
3940
<MaterialSymbolsHeightRounded class="size-4 rotate-90" />

src/lib/render/apply-scale.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ScaleOpts } from '$lib/types';
22

33
export function applyScale(canvas: OffscreenCanvas, scale: ScaleOpts): OffscreenCanvas {
44
// Nothing to do.
5+
if (scale.type === 'original') return canvas;
56
if (scale.x === 1 && scale.y === 1) return canvas;
67

78
// Scale the original image dimensions to find the closest scaled integer dimensions

src/lib/state/render-opts-state.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class RenderOptsState {
55
static default(): RenderOptsRaw {
66
return structuredClone({
77
scale: {
8-
type: 'same',
8+
type: 'original',
99
x: '1',
1010
y: '1'
1111
},

src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type AppImage = z.infer<typeof AppImage>;
2121

2222
export const ScaleOpts = z
2323
.object({
24-
type: z.literal(['same', 'different']).catch('same'),
24+
type: z.literal(['original', 'same', 'different']).catch('original'),
2525
x: z.coerce.number<string>().catch(1),
2626
y: z.coerce.number<string>().catch(1)
2727
})

0 commit comments

Comments
 (0)