Skip to content

Commit 3e05929

Browse files
committed
🐛 Fix unsigned text display background int
1 parent 8df19b6 commit 3e05929

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/systems/jsonText/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,20 @@ export class JsonText {
380380
return JsonText.intToRgba(JsonText.hexToInt(hex))
381381
}
382382

383+
static moveHex8AlphaToStart(hex: string): string {
384+
const alpha = hex.slice(-2)
385+
return '#' + alpha + hex.slice(1, -2)
386+
}
387+
383388
static hexToInt(hex: string): number {
384389
if (!hex.startsWith('#') || (hex.length !== 7 && hex.length !== 9)) {
385390
throw new Error('Invalid hex color format. Expected #RRGGBB or #AARRGGBB.')
386391
}
387392
if (hex.length === 7) {
388393
hex = '#ff' + hex.slice(1) // Add alpha
389394
}
390-
return parseInt(hex.slice(1), 16)
395+
const unsigned = parseInt(hex.slice(1), 16)
396+
return unsigned > 0x7fffffff ? unsigned - 0x100000000 : unsigned
391397
}
392398

393399
static getColor(color: TextObjectColor | TextObjectShadowColor): tinycolor.Instance {

src/systems/rigRenderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
updatePreview,
2424
} from './animationRenderer'
2525
import { IntentionalExportError } from './exporter'
26+
import { JsonText } from './jsonText'
2627

2728
export interface IRenderedFace {
2829
uv: number[]
@@ -522,7 +523,7 @@ function renderTextDisplay(display: TextDisplay, rig: IRenderedRig): INodeStruct
522523
parent: parentId,
523524
text: display.text,
524525
line_width: display.lineWidth,
525-
background_color: backgroundColor.toHexString(),
526+
background_color: JsonText.moveHex8AlphaToStart(backgroundColor.toHex8String()),
526527
background_alpha: backgroundColor.getAlpha(),
527528
align: display.align,
528529
shadow: display.shadow,

0 commit comments

Comments
 (0)