Skip to content

Commit

Permalink
refactor(common/Color): extract hardcoded colors as static members
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Aug 26, 2023
1 parent e2e726d commit 978648b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/common/Color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ export class Color {
return BinaryIO.sizeOfUint8Array(4)
}
}

static get black(): ArxColor {
return { r: 0, g: 0, b: 0, a: 1 }
}

static get transparent(): ArxColor {
return { r: 0, g: 0, b: 0, a: 0 }
}
}
4 changes: 1 addition & 3 deletions src/dlf/ZoneAndPathHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ export class ZoneAndPathHeader {
binary.writeInt32(zoneOrPath.points.length)
binary.writeBuffer(
Color.accumulateFrom(
'backgroundColor' in zoneOrPath
? zoneOrPath?.backgroundColor ?? { r: 0, g: 0, b: 0, a: 1 }
: { r: 0, g: 0, b: 0, a: 1 },
'backgroundColor' in zoneOrPath ? zoneOrPath?.backgroundColor ?? Color.black : Color.black,
'rgb',
),
)
Expand Down
4 changes: 2 additions & 2 deletions src/fts/TextureVertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ArxColor, Color } from '@common/Color'
import { ArxVector3 } from '@common/types'

const HARDCODED_DATA_TYPE1 = {
color: { r: 0, g: 0, b: 0, a: 0 } as ArxColor,
specular: { r: 0, g: 0, b: 0, a: 0 } as ArxColor,
color: Color.transparent as ArxColor,
specular: Color.transparent as ArxColor,
tu: 0,
tv: 0,
}
Expand Down

0 comments on commit 978648b

Please sign in to comment.