@hi-ashleyj/llama 0.8.1 → 0.9.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/components/drawables/Arc.svelte +3 -1
- package/components/drawables/Arc.svelte.d.ts +1 -0
- package/components/drawables/Circle.svelte +3 -1
- package/components/drawables/Circle.svelte.d.ts +1 -0
- package/components/drawables/MultiLineText.svelte +3 -1
- package/components/drawables/MultiLineText.svelte.d.ts +1 -0
- package/components/drawables/Rectangle.svelte +2 -1
- package/components/drawables/Rectangle.svelte.d.ts +1 -0
- package/components/drawables/RoundedRectangle.svelte +24 -0
- package/components/drawables/RoundedRectangle.svelte.d.ts +19 -0
- package/components/drawables/Text.svelte +8 -4
- package/components/drawables/Text.svelte.d.ts +1 -0
- package/components/drawables/index.d.ts +1 -0
- package/components/drawables/index.js +1 -0
- package/package.json +2 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
export let fill = null;
|
|
4
4
|
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
5
6
|
export let startAngle;
|
|
6
7
|
export let endAngle;
|
|
7
8
|
$: sd = (startAngle - 90) * Math.PI / 180;
|
|
@@ -15,8 +16,9 @@ const draw = function ({ ctx }, { x, y, w, h }) {
|
|
|
15
16
|
ctx.fillStyle = fill;
|
|
16
17
|
ctx.fill();
|
|
17
18
|
}
|
|
18
|
-
if (stroke) {
|
|
19
|
+
if (stroke && strokeWidth) {
|
|
19
20
|
ctx.strokeStyle = stroke;
|
|
21
|
+
ctx.lineWidth = strokeWidth;
|
|
20
22
|
ctx.stroke();
|
|
21
23
|
}
|
|
22
24
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
export let fill = null;
|
|
4
4
|
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
5
6
|
const TWO_PI = Math.PI * 2;
|
|
6
7
|
const draw = function ({ ctx }, { x, y, w, h }) {
|
|
7
8
|
let r = (w + h) / 4;
|
|
@@ -11,8 +12,9 @@ const draw = function ({ ctx }, { x, y, w, h }) {
|
|
|
11
12
|
ctx.fillStyle = fill;
|
|
12
13
|
ctx.fill();
|
|
13
14
|
}
|
|
14
|
-
if (stroke) {
|
|
15
|
+
if (stroke && strokeWidth) {
|
|
15
16
|
ctx.strokeStyle = stroke;
|
|
17
|
+
ctx.lineWidth = strokeWidth;
|
|
16
18
|
ctx.stroke();
|
|
17
19
|
}
|
|
18
20
|
};
|
|
@@ -7,6 +7,7 @@ export let font;
|
|
|
7
7
|
export let style = undefined;
|
|
8
8
|
export let fill = undefined;
|
|
9
9
|
export let stroke = undefined;
|
|
10
|
+
export let strokeWidth = null;
|
|
10
11
|
export let alignH = "left";
|
|
11
12
|
export let alignV = "top";
|
|
12
13
|
$: computedFont = (style ? style + " " : "") + size + "px " + font;
|
|
@@ -30,8 +31,9 @@ const draw = function ({ ctx }, { x, y }) {
|
|
|
30
31
|
ctx.fillStyle = fill;
|
|
31
32
|
ctx.fillText(line, x, y + size * spacing * i - offset);
|
|
32
33
|
}
|
|
33
|
-
if (stroke) {
|
|
34
|
+
if (stroke && strokeWidth) {
|
|
34
35
|
ctx.strokeStyle = stroke;
|
|
36
|
+
ctx.lineWidth = strokeWidth;
|
|
35
37
|
ctx.strokeText(line, x, y + size * spacing * i - offset);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
style?: string | undefined;
|
|
9
9
|
fill?: string | undefined;
|
|
10
10
|
stroke?: string | undefined;
|
|
11
|
+
strokeWidth?: number | null | undefined;
|
|
11
12
|
alignH?: "left" | "center" | "right" | undefined;
|
|
12
13
|
alignV?: "top" | "middle" | "bottom" | "alphabetic" | undefined;
|
|
13
14
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
3
|
export let fill = null;
|
|
4
4
|
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
5
6
|
const draw = function ({ ctx }, { x, y, w, h }) {
|
|
6
7
|
ctx.beginPath();
|
|
7
8
|
ctx.rect(x, y, w, h);
|
|
@@ -9,7 +10,7 @@ const draw = function ({ ctx }, { x, y, w, h }) {
|
|
|
9
10
|
ctx.fillStyle = fill;
|
|
10
11
|
ctx.fill();
|
|
11
12
|
}
|
|
12
|
-
if (stroke) {
|
|
13
|
+
if (stroke && strokeWidth) {
|
|
13
14
|
ctx.strokeStyle = stroke;
|
|
14
15
|
ctx.stroke();
|
|
15
16
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>import { setupDrawable } from "../../setup";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let fill = null;
|
|
4
|
+
export let stroke = null;
|
|
5
|
+
export let strokeWidth = null;
|
|
6
|
+
export let radius = 0;
|
|
7
|
+
const draw = function ({ ctx }, { x, y, w, h }) {
|
|
8
|
+
ctx.beginPath();
|
|
9
|
+
ctx.roundRect(x, y, w, h, radius);
|
|
10
|
+
if (fill) {
|
|
11
|
+
ctx.fillStyle = fill;
|
|
12
|
+
ctx.fill();
|
|
13
|
+
}
|
|
14
|
+
if (stroke && strokeWidth) {
|
|
15
|
+
ctx.strokeStyle = stroke;
|
|
16
|
+
ctx.lineWidth = strokeWidth;
|
|
17
|
+
ctx.stroke();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
let register = setupDrawable({});
|
|
21
|
+
onMount(() => {
|
|
22
|
+
return register({ draw });
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
fill?: string | null | undefined;
|
|
5
|
+
stroke?: string | null | undefined;
|
|
6
|
+
strokeWidth?: number | null | undefined;
|
|
7
|
+
radius?: number | [number] | [number, number] | [number, number, number] | [number, number, number, number] | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type RoundedRectangleProps = typeof __propDef.props;
|
|
15
|
+
export type RoundedRectangleEvents = typeof __propDef.events;
|
|
16
|
+
export type RoundedRectangleSlots = typeof __propDef.slots;
|
|
17
|
+
export default class RoundedRectangle extends SvelteComponentTyped<RoundedRectangleProps, RoundedRectangleEvents, RoundedRectangleSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -6,23 +6,27 @@ export let font;
|
|
|
6
6
|
export let style = undefined;
|
|
7
7
|
export let fill = undefined;
|
|
8
8
|
export let stroke = undefined;
|
|
9
|
+
export let strokeWidth = null;
|
|
9
10
|
export let alignH = "left";
|
|
10
11
|
export let alignV = "top";
|
|
11
12
|
$: computedFont = ((style) ? style + " " : "") + size + "px " + font;
|
|
12
|
-
const draw = function ({ ctx }, { x, y }) {
|
|
13
|
+
const draw = function ({ ctx }, { x, y, w, h }) {
|
|
13
14
|
if (!text)
|
|
14
15
|
return;
|
|
15
16
|
ctx.beginPath();
|
|
16
17
|
ctx.textAlign = alignH;
|
|
17
18
|
ctx.textBaseline = alignV;
|
|
18
19
|
ctx.font = computedFont;
|
|
20
|
+
let actualX = x + (alignH === "right" ? w : alignH === "center" ? w / 2 : 0);
|
|
21
|
+
let actualY = y + (alignV === "bottom" ? h : alignV === "middle" ? (h / 2) + (size * 0.10) : 0);
|
|
19
22
|
if (fill) {
|
|
20
23
|
ctx.fillStyle = fill;
|
|
21
|
-
ctx.fillText(text,
|
|
24
|
+
ctx.fillText(text, actualX, actualY);
|
|
22
25
|
}
|
|
23
|
-
if (stroke) {
|
|
26
|
+
if (stroke && strokeWidth) {
|
|
24
27
|
ctx.strokeStyle = stroke;
|
|
25
|
-
ctx.
|
|
28
|
+
ctx.lineWidth = strokeWidth;
|
|
29
|
+
ctx.strokeText(text, actualX, actualY);
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
32
|
let register = setupDrawable({});
|
|
@@ -7,6 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
style?: string | undefined;
|
|
8
8
|
fill?: string | undefined;
|
|
9
9
|
stroke?: string | undefined;
|
|
10
|
+
strokeWidth?: number | null | undefined;
|
|
10
11
|
alignH?: "left" | "center" | "right" | undefined;
|
|
11
12
|
alignV?: "top" | "middle" | "bottom" | "alphabetic" | undefined;
|
|
12
13
|
};
|
|
@@ -4,3 +4,4 @@ export { default as Arc } from "./Arc.svelte";
|
|
|
4
4
|
export { default as DisplayImage } from "./DisplayImage.svelte";
|
|
5
5
|
export { default as Text } from "./Text.svelte";
|
|
6
6
|
export { default as MultiLineText } from "./MultiLineText.svelte";
|
|
7
|
+
export { default as RoundedRectangle } from "./RoundedRectangle.svelte";
|
|
@@ -4,3 +4,4 @@ export { default as Arc } from "./Arc.svelte";
|
|
|
4
4
|
export { default as DisplayImage } from "./DisplayImage.svelte";
|
|
5
5
|
export { default as Text } from "./Text.svelte";
|
|
6
6
|
export { default as MultiLineText } from "./MultiLineText.svelte";
|
|
7
|
+
export { default as RoundedRectangle } from "./RoundedRectangle.svelte";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ashleyj/llama",
|
|
3
3
|
"description": "A (Very Incomplete) 2D Canvas Game Engine powered by Svelte",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"./components/drawables/DisplayImage.svelte": "./components/drawables/DisplayImage.svelte",
|
|
36
36
|
"./components/drawables/MultiLineText.svelte": "./components/drawables/MultiLineText.svelte",
|
|
37
37
|
"./components/drawables/Rectangle.svelte": "./components/drawables/Rectangle.svelte",
|
|
38
|
+
"./components/drawables/RoundedRectangle.svelte": "./components/drawables/RoundedRectangle.svelte",
|
|
38
39
|
"./components/drawables/Text.svelte": "./components/drawables/Text.svelte",
|
|
39
40
|
"./components/drawables": "./components/drawables/index.js",
|
|
40
41
|
"./components/motions": "./components/motions.js",
|