@hi-ashleyj/llama 0.8.1 → 0.8.2
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.
|
@@ -9,20 +9,22 @@ export let stroke = undefined;
|
|
|
9
9
|
export let alignH = "left";
|
|
10
10
|
export let alignV = "top";
|
|
11
11
|
$: computedFont = ((style) ? style + " " : "") + size + "px " + font;
|
|
12
|
-
const draw = function ({ ctx }, { x, y }) {
|
|
12
|
+
const draw = function ({ ctx }, { x, y, w, h }) {
|
|
13
13
|
if (!text)
|
|
14
14
|
return;
|
|
15
15
|
ctx.beginPath();
|
|
16
16
|
ctx.textAlign = alignH;
|
|
17
17
|
ctx.textBaseline = alignV;
|
|
18
18
|
ctx.font = computedFont;
|
|
19
|
+
let actualX = x + (alignH === "right" ? w : alignH === "center" ? w / 2 : 0);
|
|
20
|
+
let actualY = y + (alignV === "bottom" ? h : alignV === "middle" ? (h / 2) + (size * 0.10) : 0);
|
|
19
21
|
if (fill) {
|
|
20
22
|
ctx.fillStyle = fill;
|
|
21
|
-
ctx.fillText(text,
|
|
23
|
+
ctx.fillText(text, actualX, actualY);
|
|
22
24
|
}
|
|
23
25
|
if (stroke) {
|
|
24
26
|
ctx.strokeStyle = stroke;
|
|
25
|
-
ctx.strokeText(text,
|
|
27
|
+
ctx.strokeText(text, actualX, actualY);
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
30
|
let register = setupDrawable({});
|