laymur 0.3.26 → 0.3.27
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/index.js
CHANGED
|
@@ -6273,6 +6273,7 @@ const DEFAULT_TEXT_STYLE = {
|
|
|
6273
6273
|
fontFamily: "Arial",
|
|
6274
6274
|
fontSize: 16,
|
|
6275
6275
|
fontStyle: "normal",
|
|
6276
|
+
fontWeight: "normal",
|
|
6276
6277
|
lineHeight: 1.2,
|
|
6277
6278
|
enableShadow: false,
|
|
6278
6279
|
shadowOffsetX: 0,
|
|
@@ -6449,14 +6450,23 @@ function renderText(x, y, text, style, context) {
|
|
|
6449
6450
|
context.strokeText(text, x, y);
|
|
6450
6451
|
}
|
|
6451
6452
|
context.fillStyle = style.color;
|
|
6452
|
-
context.textAlign = style.align;
|
|
6453
6453
|
context.fillText(text, x, y);
|
|
6454
6454
|
}
|
|
6455
|
-
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
6455
|
+
function renderTextLines(paddingTop, paddingLeft, lines, context, maxWidth) {
|
|
6456
6456
|
let currentY = paddingTop;
|
|
6457
6457
|
for (let i = 0; i < lines.length; i++) {
|
|
6458
6458
|
const line = lines[i];
|
|
6459
|
-
|
|
6459
|
+
const firstAlign = line.chunks[0]?.style.align ?? DEFAULT_TEXT_STYLE.align;
|
|
6460
|
+
const isUniformAlign = line.chunks.every((c) => c.style.align === firstAlign);
|
|
6461
|
+
const lineAlign = isUniformAlign ? firstAlign : DEFAULT_TEXT_STYLE.align;
|
|
6462
|
+
let offsetX = 0;
|
|
6463
|
+
if (lineAlign === "center") {
|
|
6464
|
+
offsetX = (maxWidth - line.width) / 2;
|
|
6465
|
+
}
|
|
6466
|
+
else if (lineAlign === "right") {
|
|
6467
|
+
offsetX = maxWidth - line.width;
|
|
6468
|
+
}
|
|
6469
|
+
let currentX = paddingLeft + offsetX;
|
|
6460
6470
|
currentY += i === 0 ? line.height : line.lineHeight;
|
|
6461
6471
|
for (const chunk of line.chunks) {
|
|
6462
6472
|
renderText(currentX, currentY, chunk.text, chunk.style, context);
|
|
@@ -6670,7 +6680,7 @@ class UIText extends UIElement {
|
|
|
6670
6680
|
this.width = this._private_canvas.width;
|
|
6671
6681
|
this.height = this._private_canvas.height;
|
|
6672
6682
|
this._private_targetAspectRatio = this._private_canvas.width / this._private_canvas.height;
|
|
6673
|
-
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
|
|
6683
|
+
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context, this.maxWidth);
|
|
6674
6684
|
this._private_texture.dispose();
|
|
6675
6685
|
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
6676
6686
|
this._private_texture.needsUpdate = true;
|
|
@@ -7365,5 +7375,5 @@ function isUITextSpan(obj) {
|
|
|
7365
7375
|
(!("style" in obj) || isUITextStyle(obj.style)));
|
|
7366
7376
|
}
|
|
7367
7377
|
|
|
7368
|
-
export { UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
7378
|
+
export { DEFAULT_TEXT_STYLE, UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
7369
7379
|
//# sourceMappingURL=index.js.map
|