@kubohiroya/turbowarp-svg-text 0.2.0 → 0.2.1
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/README.md +1 -1
- package/dist/svg-text.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Defines or replaces a named style. `ALIGN` accepts `left`, `center`, or `right`.
|
|
|
42
42
|
| `up-left` | `northwest` |
|
|
43
43
|
| `up-up-left` | `north-northwest` |
|
|
44
44
|
|
|
45
|
-
Direction input is trimmed and case-insensitive.
|
|
45
|
+
Direction input is trimmed and case-insensitive. Direction is measured from the actor center to the bubble body center. Changing the bubble width or height does not change the requested angle, although stage-edge clamping can move the bubble when necessary.
|
|
46
46
|
|
|
47
47
|
`DIRECTION` also accepts any number from `0` through `360` and uses Scratch sprite direction semantics: `0` is up, `90` is right, `180` is down, `270` is left, and `360` is up again. Values between the named directions are placed continuously without rounding to the nearest of the sixteen menu positions. Values outside this range fall back to the initial `up-right` direction.
|
|
48
48
|
|
package/dist/svg-text.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"opcode": "defineStyle",
|
|
25
25
|
"blockType": "COMMAND",
|
|
26
26
|
"text": "define text style [STYLE] background [BACKGROUND] text [TEXT_COLOR] font [FONT] size [SIZE] align [ALIGN] bubble direction [DIRECTION]",
|
|
27
|
-
"description": "Defines or replaces a named responsive text style. Bubble direction accepts names, compass aliases, or Scratch-style degrees from 0 to 360.",
|
|
27
|
+
"description": "Defines or replaces a named responsive text style. Bubble direction is measured from the actor center to the bubble body center and accepts names, compass aliases, or Scratch-style degrees from 0 to 360.",
|
|
28
28
|
"arguments": {
|
|
29
29
|
"STYLE": {
|
|
30
30
|
"type": "STRING",
|
|
@@ -651,9 +651,9 @@
|
|
|
651
651
|
const vector = directionVector(direction);
|
|
652
652
|
const horizontalDistance = vector.x < 0 ? centeredBubbleX - leftBubbleX : rightBubbleX - centeredBubbleX;
|
|
653
653
|
const verticalDistance = vector.y < 0 ? centeredBubbleY - lowerBubbleY : upperBubbleY - centeredBubbleY;
|
|
654
|
-
const
|
|
655
|
-
let x = centeredBubbleX + vector.x *
|
|
656
|
-
let y = centeredBubbleY + vector.y *
|
|
654
|
+
const placementScale = Math.min(vector.x === 0 ? Number.POSITIVE_INFINITY : horizontalDistance / Math.abs(vector.x), vector.y === 0 ? Number.POSITIVE_INFINITY : verticalDistance / Math.abs(vector.y));
|
|
655
|
+
let x = centeredBubbleX + vector.x * placementScale;
|
|
656
|
+
let y = centeredBubbleY + vector.y * placementScale;
|
|
657
657
|
if (vector.x > 0 && !bubbleState.onSpriteRight) {
|
|
658
658
|
bubbleState.onSpriteRight = true;
|
|
659
659
|
this.updateTextSkin(bubbleState);
|
package/package.json
CHANGED