Skip to content

Commit

Permalink
🐛 Fix composite argb color provider not wrapping to negatives (#1642)
Browse files Browse the repository at this point in the history
  • Loading branch information
misode authored Nov 22, 2024
1 parent 6e0e705 commit dbae237
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/core/src/processor/ColorInfoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ export namespace Color {
* @param value `A << 24 + R << 16 + G << 8 + B`.
*/
export function fromCompositeARGB(value: number): Color {
const b = value % 256
value >>>= 8
const g = value % 256
value >>>= 8
const r = value % 256
value >>>= 8
const a = value % 256
value |= 0 // Cast to signed 32-bit integer

const a = (value >>> 24) & 0xff
const r = (value >>> 16) & 0xff
const g = (value >>> 8) & 0xff
const b = value & 0xff

return fromIntRGBA(r, g, b, a)
}
}
Expand Down Expand Up @@ -194,10 +194,12 @@ export namespace ColorPresentation {
}`
case ColorFormat.CompositeARGB:
return `${
(BigInt(Math.round(color[3] * 255)) << 24n)
+ (BigInt(Math.round(color[0] * 255)) << 16n)
+ (BigInt(Math.round(color[1] * 255)) << 8n)
+ BigInt(Math.round(color[2] * 255))
Number(
(BigInt(Math.round(color[3] * 255)) << 24n)
+ (BigInt(Math.round(color[0] * 255)) << 16n)
+ (BigInt(Math.round(color[1] * 255)) << 8n)
+ BigInt(Math.round(color[2] * 255)),
) << 0 // Convert to signed 32-bit integer
}`
}
}
Expand Down

0 comments on commit dbae237

Please sign in to comment.