Add Tweening to zoom, fix saving canvas.

This commit is contained in:
2025-01-14 00:04:14 +01:00
parent 4433cf0e00
commit 76db788192
9 changed files with 222 additions and 127 deletions

View File

@@ -1,5 +1,5 @@
import type { CanvasContent } from '~/types/canvas';
import type { FileType } from '~/types/content';
import type { ContentMap, FileType } from '~/types/content';
export function unifySlug(slug: string | string[]): string
{
@@ -47,7 +47,10 @@ export function clamp(x: number, min: number, max: number): number {
return min;
return x;
}
export function convertContent(type: FileType, content: string): CanvasContent | string {
export function lerp(a: number, b: number, t: number) {
return a + t * (b - a);
}
export function convertContentFromText(type: FileType, content: string): CanvasContent | string {
switch(type)
{
case 'canvas':
@@ -61,6 +64,20 @@ export function convertContent(type: FileType, content: string): CanvasContent |
return content;
}
}
export function convertContentToText(type: FileType, content: any): string {
switch(type)
{
case 'canvas':
return JSON.stringify(content);
case 'map':
case 'file':
case 'folder':
case 'markdown':
return content;
default:
return content;
}
}
export const iconByType: Record<FileType, string> = {
'folder': 'lucide:folder',