@hi-ashleyj/llama 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Game.svelte +154 -129
- package/dist/Game.svelte.d.ts +10 -21
- package/dist/Layer.svelte +61 -46
- package/dist/Layer.svelte.d.ts +9 -20
- package/dist/audio/AudioCompressor.svelte +70 -44
- package/dist/audio/AudioCompressor.svelte.d.ts +14 -23
- package/dist/audio/AudioGain.svelte +33 -20
- package/dist/audio/AudioGain.svelte.d.ts +6 -17
- package/dist/audio/AudioListenerPosition.svelte +79 -93
- package/dist/audio/AudioListenerPosition.svelte.d.ts +6 -16
- package/dist/audio/AudioPanner.svelte +33 -20
- package/dist/audio/AudioPanner.svelte.d.ts +6 -17
- package/dist/audio/BufferedAudioSource.svelte +59 -44
- package/dist/audio/BufferedAudioSource.svelte.d.ts +8 -18
- package/dist/audio/MediaAudioSource.svelte +56 -35
- package/dist/audio/MediaAudioSource.svelte.d.ts +13 -25
- package/dist/audio/context.d.ts +1 -1
- package/dist/controllers/MouseClickable.svelte +61 -49
- package/dist/controllers/MouseClickable.svelte.d.ts +11 -20
- package/dist/controllers/MouseEventArea.svelte +71 -55
- package/dist/controllers/MouseEventArea.svelte.d.ts +13 -26
- package/dist/controllers/motions.d.ts +4 -5
- package/dist/drawables/Arc.svelte +48 -30
- package/dist/drawables/Arc.svelte.d.ts +9 -19
- package/dist/drawables/Circle.svelte +38 -24
- package/dist/drawables/Circle.svelte.d.ts +7 -17
- package/dist/drawables/DisplayImage.svelte +26 -16
- package/dist/drawables/DisplayImage.svelte.d.ts +11 -21
- package/dist/drawables/MultiLineText.svelte +75 -45
- package/dist/drawables/MultiLineText.svelte.d.ts +14 -24
- package/dist/drawables/Rectangle.svelte +35 -22
- package/dist/drawables/Rectangle.svelte.d.ts +7 -17
- package/dist/drawables/RoundedRectangle.svelte +41 -23
- package/dist/drawables/RoundedRectangle.svelte.d.ts +8 -18
- package/dist/drawables/Text.svelte +63 -40
- package/dist/drawables/Text.svelte.d.ts +13 -23
- package/dist/drawables/Tiled.svelte +79 -61
- package/dist/drawables/Tiled.svelte.d.ts +10 -20
- package/dist/extras/DefaultFontFace.svelte +35 -17
- package/dist/extras/DefaultFontFace.svelte.d.ts +15 -24
- package/dist/extras/FullScreenEventHandler.svelte +37 -23
- package/dist/extras/FullScreenEventHandler.svelte.d.ts +9 -19
- package/dist/extras/LayerPortal.svelte +36 -22
- package/dist/extras/LayerPortal.svelte.d.ts +6 -17
- package/dist/extras/SensibleDefaultStyles.svelte +8 -2
- package/dist/extras/SensibleDefaultStyles.svelte.d.ts +5 -17
- package/dist/extras/Tweened.svelte +28 -9
- package/dist/extras/Tweened.svelte.d.ts +12 -22
- package/dist/primitives/Area.svelte +46 -22
- package/dist/primitives/Area.svelte.d.ts +14 -24
- package/dist/primitives/Empty.svelte +7 -2
- package/dist/primitives/Empty.svelte.d.ts +5 -15
- package/dist/primitives/Inset.svelte +45 -26
- package/dist/primitives/Inset.svelte.d.ts +9 -20
- package/dist/primitives/Node.svelte +32 -19
- package/dist/primitives/Node.svelte.d.ts +7 -18
- package/dist/primitives/Opacity.svelte +34 -22
- package/dist/primitives/Opacity.svelte.d.ts +6 -17
- package/dist/primitives/Rotate.svelte +33 -22
- package/dist/primitives/Rotate.svelte.d.ts +11 -21
- package/dist/primitives/Translate.svelte +32 -19
- package/dist/primitives/Translate.svelte.d.ts +7 -18
- package/dist/resources/AssetPool.svelte +7 -2
- package/dist/resources/AssetPool.svelte.d.ts +5 -15
- package/dist/resources/AudioBufferedAsset.svelte +14 -6
- package/dist/resources/AudioBufferedAsset.svelte.d.ts +5 -15
- package/dist/resources/AudioMediaAsset.svelte +10 -2
- package/dist/resources/AudioMediaAsset.svelte.d.ts +5 -15
- package/dist/resources/ImageAsset.svelte +16 -9
- package/dist/resources/ImageAsset.svelte.d.ts +5 -15
- package/dist/resources/audio.d.ts +1 -1
- package/dist/resources/images.d.ts +1 -1
- package/dist/scenes/SceneSwitcher.svelte +27 -16
- package/dist/scenes/SceneSwitcher.svelte.d.ts +5 -16
- package/dist/scenes/SceneTransition.svelte +47 -36
- package/dist/scenes/SceneTransition.svelte.d.ts +6 -20
- package/package.json +10 -9
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { getGame } from "../core-contexts.js";
|
|
4
|
+
import { setupDrawable, type DrawFunction } from "../drawable.js";
|
|
5
|
+
import { onMount } from "svelte";
|
|
6
|
+
import { MOUSE_ACTION } from "./mouse.js";
|
|
7
|
+
|
|
8
|
+
let tx = 0;
|
|
9
|
+
let ty = 0;
|
|
10
|
+
let tw = 0;
|
|
11
|
+
let th = 0;
|
|
12
|
+
|
|
13
|
+
let context = getGame();
|
|
14
|
+
|
|
15
|
+
type Click = () => void;
|
|
16
|
+
let {
|
|
17
|
+
onleft,
|
|
18
|
+
onright,
|
|
19
|
+
onleftorright,
|
|
20
|
+
onclick,
|
|
21
|
+
onmiddle,
|
|
22
|
+
onother
|
|
23
|
+
}: {
|
|
24
|
+
onleft: Click,
|
|
25
|
+
onright: Click,
|
|
26
|
+
onleftorright: Click,
|
|
27
|
+
onclick: Click,
|
|
28
|
+
onmiddle: Click,
|
|
29
|
+
onother: Click,
|
|
30
|
+
} = $props();
|
|
31
|
+
|
|
32
|
+
const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function(_info, { x, y, w, h }) {
|
|
33
|
+
tx = x;
|
|
34
|
+
ty = y;
|
|
35
|
+
tw = w;
|
|
36
|
+
th = h;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
|
|
40
|
+
|
|
41
|
+
onMount(() => {
|
|
42
|
+
let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
|
|
43
|
+
let x = context.getMousePosition("mouse_x");
|
|
44
|
+
if (x < tx || x > tx + tw) return;
|
|
45
|
+
let y = context.getMousePosition("mouse_y");
|
|
46
|
+
if (y < ty || y > ty + th) return;
|
|
47
|
+
onclick();
|
|
48
|
+
switch (key) {
|
|
49
|
+
case ("mouse_left"): { onleft(); onleftorright(); return; }
|
|
50
|
+
case ("mouse_right"): { onright(); onleftorright(); return; }
|
|
51
|
+
case ("mouse_middle"): { onmiddle; }
|
|
52
|
+
}
|
|
53
|
+
onother();
|
|
54
|
+
});
|
|
55
|
+
let deregister = register({ draw });
|
|
56
|
+
return () => {
|
|
57
|
+
event();
|
|
58
|
+
deregister();
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
50
62
|
</script>
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
middle: CustomEvent<any>;
|
|
10
|
-
other: CustomEvent<any>;
|
|
11
|
-
} & {
|
|
12
|
-
[evt: string]: CustomEvent<any>;
|
|
13
|
-
};
|
|
14
|
-
slots: {};
|
|
1
|
+
type Click = () => void;
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
onleft: Click;
|
|
4
|
+
onright: Click;
|
|
5
|
+
onleftorright: Click;
|
|
6
|
+
onclick: Click;
|
|
7
|
+
onmiddle: Click;
|
|
8
|
+
onother: Click;
|
|
15
9
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
export default class MouseClickable extends SvelteComponent<MouseClickableProps, MouseClickableEvents, MouseClickableSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
10
|
+
declare const MouseClickable: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type MouseClickable = ReturnType<typeof MouseClickable>;
|
|
12
|
+
export default MouseClickable;
|
|
@@ -1,58 +1,74 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
if ($mouseY < ty || $mouseY > ty + th)
|
|
31
|
-
return;
|
|
32
|
-
dispatch("click");
|
|
33
|
-
switch (key) {
|
|
34
|
-
case "mouse_left": {
|
|
35
|
-
dispatch("left");
|
|
36
|
-
dispatch("leftorright");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
case "mouse_right": {
|
|
40
|
-
dispatch("right");
|
|
41
|
-
dispatch("leftorright");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
case "mouse_middle": {
|
|
45
|
-
dispatch("middle");
|
|
46
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { getGame } from "../core-contexts.js";
|
|
4
|
+
import { setupDrawable, type DrawFunction } from "../drawable.js";
|
|
5
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
6
|
+
import { MOUSE_ACTION } from "./mouse.js";
|
|
7
|
+
|
|
8
|
+
let tx = 0;
|
|
9
|
+
let ty = 0;
|
|
10
|
+
let tw = 0;
|
|
11
|
+
let th = 0;
|
|
12
|
+
|
|
13
|
+
let dispatch = createEventDispatcher();
|
|
14
|
+
let context = getGame();
|
|
15
|
+
|
|
16
|
+
let mouseX = context.getMouseStore("mouse_x");
|
|
17
|
+
let mouseY = context.getMouseStore("mouse_y");
|
|
18
|
+
|
|
19
|
+
type Click = () => void;
|
|
20
|
+
interface Props {
|
|
21
|
+
hover?: boolean;
|
|
22
|
+
children?: import('svelte').Snippet<[any]>;
|
|
23
|
+
onleft: Click;
|
|
24
|
+
onright: Click;
|
|
25
|
+
onleftorright: Click;
|
|
26
|
+
onclick: Click;
|
|
27
|
+
onmiddle: Click;
|
|
28
|
+
onother: Click;
|
|
47
29
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
|
|
31
|
+
let { hover = $bindable(false), children,
|
|
32
|
+
onleft,
|
|
33
|
+
onright,
|
|
34
|
+
onleftorright,
|
|
35
|
+
onclick,
|
|
36
|
+
onmiddle,
|
|
37
|
+
onother
|
|
38
|
+
}: Props = $props();
|
|
39
|
+
|
|
40
|
+
const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function(_info, { x, y, w, h }) {
|
|
41
|
+
tx = x;
|
|
42
|
+
ty = y;
|
|
43
|
+
tw = w;
|
|
44
|
+
th = h;
|
|
45
|
+
|
|
46
|
+
if ($mouseX < tx || $mouseX > tx + tw) return hover = false;
|
|
47
|
+
if ($mouseY < ty || $mouseY > ty + th) return hover = false;
|
|
48
|
+
hover = true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
|
|
52
|
+
|
|
53
|
+
onMount(() => {
|
|
54
|
+
let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
|
|
55
|
+
if ($mouseX < tx || $mouseX > tx + tw) return;
|
|
56
|
+
if ($mouseY < ty || $mouseY > ty + th) return;
|
|
57
|
+
onclick();
|
|
58
|
+
switch (key) {
|
|
59
|
+
case ("mouse_left"): { onleft(); onleftorright(); return; }
|
|
60
|
+
case ("mouse_right"): { onright(); onleftorright(); return; }
|
|
61
|
+
case ("mouse_middle"): { onmiddle; }
|
|
62
|
+
}
|
|
63
|
+
onother();
|
|
64
|
+
});
|
|
65
|
+
let deregister = register({ draw });
|
|
66
|
+
return () => {
|
|
67
|
+
event();
|
|
68
|
+
deregister();
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
56
72
|
</script>
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
{@render children?.({ hover, })}
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
middle: CustomEvent<any>;
|
|
12
|
-
other: CustomEvent<any>;
|
|
13
|
-
} & {
|
|
14
|
-
[evt: string]: CustomEvent<any>;
|
|
15
|
-
};
|
|
16
|
-
slots: {
|
|
17
|
-
default: {
|
|
18
|
-
hover: boolean;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type MouseEventAreaProps = typeof __propDef.props;
|
|
23
|
-
export type MouseEventAreaEvents = typeof __propDef.events;
|
|
24
|
-
export type MouseEventAreaSlots = typeof __propDef.slots;
|
|
25
|
-
export default class MouseEventArea extends SvelteComponent<MouseEventAreaProps, MouseEventAreaEvents, MouseEventAreaSlots> {
|
|
1
|
+
type Click = () => void;
|
|
2
|
+
interface Props {
|
|
3
|
+
hover?: boolean;
|
|
4
|
+
children?: import('svelte').Snippet<[any]>;
|
|
5
|
+
onleft: Click;
|
|
6
|
+
onright: Click;
|
|
7
|
+
onleftorright: Click;
|
|
8
|
+
onclick: Click;
|
|
9
|
+
onmiddle: Click;
|
|
10
|
+
onother: Click;
|
|
26
11
|
}
|
|
27
|
-
|
|
12
|
+
declare const MouseEventArea: import("svelte").Component<Props, {}, "hover">;
|
|
13
|
+
type MouseEventArea = ReturnType<typeof MouseEventArea>;
|
|
14
|
+
export default MouseEventArea;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
1
|
import type { Writable } from "svelte/store";
|
|
3
2
|
export declare class Timing {
|
|
4
3
|
constructor();
|
|
@@ -18,10 +17,10 @@ export declare class Timing {
|
|
|
18
17
|
duration: number;
|
|
19
18
|
repeats: number;
|
|
20
19
|
}): {
|
|
21
|
-
stop: () =>
|
|
20
|
+
stop: () => any;
|
|
22
21
|
set(this: void, value: number): void;
|
|
23
22
|
update(this: void, updater: import("svelte/store").Updater<number>): void;
|
|
24
|
-
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?:
|
|
23
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: () => void): import("svelte/store").Unsubscriber;
|
|
25
24
|
};
|
|
26
25
|
/**
|
|
27
26
|
* Used to create a store whose value adjusts based on bursts.
|
|
@@ -31,11 +30,11 @@ export declare class Timing {
|
|
|
31
30
|
duration: number;
|
|
32
31
|
initialTrigger?: boolean;
|
|
33
32
|
}): {
|
|
34
|
-
stop: () =>
|
|
33
|
+
stop: () => any;
|
|
35
34
|
trigger: () => void;
|
|
36
35
|
set(this: void, value: number): void;
|
|
37
36
|
update(this: void, updater: import("svelte/store").Updater<number>): void;
|
|
38
|
-
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?:
|
|
37
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: () => void): import("svelte/store").Unsubscriber;
|
|
39
38
|
};
|
|
40
39
|
update(delta: number): void;
|
|
41
40
|
}
|
|
@@ -1,31 +1,49 @@
|
|
|
1
|
-
<script
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { setupDrawable, type DrawFunction } from "../drawable.js";
|
|
4
|
+
import { onMount } from "svelte";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
fill?: string | null;
|
|
8
|
+
stroke?: string | null;
|
|
9
|
+
strokeWidth?: number | null;
|
|
10
|
+
startAngle: number;
|
|
11
|
+
endAngle: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
fill = null,
|
|
16
|
+
stroke = null,
|
|
17
|
+
strokeWidth = null,
|
|
18
|
+
startAngle,
|
|
19
|
+
endAngle
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
|
|
22
|
+
let sd = $derived((startAngle - 90) * Math.PI / 180);
|
|
23
|
+
let ed = $derived((endAngle - 90) * Math.PI / 180);
|
|
24
|
+
|
|
25
|
+
const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
|
|
26
|
+
let r = (w + h) / 4
|
|
27
|
+
|
|
28
|
+
ctx.beginPath();
|
|
29
|
+
ctx.arc(x + r, y + r, r, sd, ed);
|
|
30
|
+
ctx.lineTo(x + r, y + r);
|
|
31
|
+
|
|
32
|
+
if (fill) {
|
|
33
|
+
ctx.fillStyle = fill;
|
|
34
|
+
ctx.fill();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (stroke && strokeWidth) {
|
|
38
|
+
ctx.strokeStyle = stroke;
|
|
39
|
+
ctx.lineWidth = strokeWidth;
|
|
40
|
+
ctx.stroke();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
|
|
45
|
+
|
|
46
|
+
onMount(() => {
|
|
47
|
+
return register({ draw });
|
|
48
|
+
})
|
|
31
49
|
</script>
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
startAngle: number;
|
|
8
|
-
endAngle: number;
|
|
9
|
-
};
|
|
10
|
-
events: {
|
|
11
|
-
[evt: string]: CustomEvent<any>;
|
|
12
|
-
};
|
|
13
|
-
slots: {};
|
|
14
|
-
};
|
|
15
|
-
export type ArcProps = typeof __propDef.props;
|
|
16
|
-
export type ArcEvents = typeof __propDef.events;
|
|
17
|
-
export type ArcSlots = typeof __propDef.slots;
|
|
18
|
-
export default class Arc extends SvelteComponent<ArcProps, ArcEvents, ArcSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
fill?: string | null;
|
|
3
|
+
stroke?: string | null;
|
|
4
|
+
strokeWidth?: number | null;
|
|
5
|
+
startAngle: number;
|
|
6
|
+
endAngle: number;
|
|
19
7
|
}
|
|
20
|
-
|
|
8
|
+
declare const Arc: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type Arc = ReturnType<typeof Arc>;
|
|
10
|
+
export default Arc;
|
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { setupDrawable, type DrawFunction } from "../drawable.js";
|
|
4
|
+
import { onMount } from "svelte";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
fill?: string | null;
|
|
8
|
+
stroke?: string | null;
|
|
9
|
+
strokeWidth?: number | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { fill = null, stroke = null, strokeWidth = null }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const TWO_PI = Math.PI * 2;
|
|
15
|
+
|
|
16
|
+
const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
|
|
17
|
+
let r = (w + h) / 4
|
|
18
|
+
|
|
19
|
+
ctx.beginPath();
|
|
20
|
+
ctx.arc(x + r, y + r, r, 0, TWO_PI);
|
|
21
|
+
|
|
22
|
+
if (fill) {
|
|
23
|
+
ctx.fillStyle = fill;
|
|
24
|
+
ctx.fill();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (stroke && strokeWidth) {
|
|
28
|
+
ctx.strokeStyle = stroke;
|
|
29
|
+
ctx.lineWidth = strokeWidth;
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
|
|
35
|
+
|
|
36
|
+
onMount(() => {
|
|
37
|
+
return register({ draw });
|
|
38
|
+
})
|
|
25
39
|
</script>
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
stroke?: string | null | undefined;
|
|
6
|
-
strokeWidth?: number | null | undefined;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
};
|
|
13
|
-
export type CircleProps = typeof __propDef.props;
|
|
14
|
-
export type CircleEvents = typeof __propDef.events;
|
|
15
|
-
export type CircleSlots = typeof __propDef.slots;
|
|
16
|
-
export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
fill?: string | null;
|
|
3
|
+
stroke?: string | null;
|
|
4
|
+
strokeWidth?: number | null;
|
|
17
5
|
}
|
|
18
|
-
|
|
6
|
+
declare const Circle: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type Circle = ReturnType<typeof Circle>;
|
|
8
|
+
export default Circle;
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { setupDrawable, type DrawFunction} from "../drawable.js";
|
|
4
|
+
import { onMount } from "svelte";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
image?: HTMLImageElement | null;
|
|
8
|
+
crop?: { x: number, y: number, w: number, h: number } | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { image = null, crop = null }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
|
|
14
|
+
if (!image) return;
|
|
15
|
+
if (crop) {
|
|
16
|
+
return ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, x, y, w, h);
|
|
17
|
+
}
|
|
18
|
+
ctx.drawImage(image, x, y, w, h);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
|
|
22
|
+
|
|
23
|
+
onMount(() => {
|
|
24
|
+
return register({ draw });
|
|
25
|
+
})
|
|
26
|
+
|
|
17
27
|
</script>
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
h: number;
|
|
10
|
-
} | null | undefined;
|
|
11
|
-
};
|
|
12
|
-
events: {
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {};
|
|
16
|
-
};
|
|
17
|
-
export type DisplayImageProps = typeof __propDef.props;
|
|
18
|
-
export type DisplayImageEvents = typeof __propDef.events;
|
|
19
|
-
export type DisplayImageSlots = typeof __propDef.slots;
|
|
20
|
-
export default class DisplayImage extends SvelteComponent<DisplayImageProps, DisplayImageEvents, DisplayImageSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
image?: HTMLImageElement | null;
|
|
3
|
+
crop?: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
} | null;
|
|
21
9
|
}
|
|
22
|
-
|
|
10
|
+
declare const DisplayImage: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type DisplayImage = ReturnType<typeof DisplayImage>;
|
|
12
|
+
export default DisplayImage;
|