Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix composite argb color provider not wrapping to negatives #1642

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading