-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b454e91
commit 73d5689
Showing
6 changed files
with
305 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** can be RGB or RGBA. */ | ||
export interface RGBA { | ||
red: number; | ||
green: number; | ||
blue: number; | ||
alpha?: number; | ||
} | ||
|
||
export class RGBColor implements RGBA { | ||
/** | ||
* RGB(A) color class, allows for RGB(A) colors to be converted to a Number, among other things. | ||
* Internally always RGBA. | ||
* @param red | ||
* @param green | ||
* @param blue | ||
* @param alpha | ||
*/ | ||
constructor(public red: number, public green: number, public blue: number, public alpha?: number) {} | ||
|
||
/** | ||
* Converts an RGB(A) value to a Number. | ||
* @returns Number from RGB(A) value | ||
*/ | ||
toNumber(): number { | ||
return (this.red << 24) | (this.green << 16) | (this.blue << 8) | (this.alpha !== undefined ? this.alpha : 255); | ||
} | ||
} | ||
|
||
/** RGB pixel formats */ | ||
export enum RGBFormat { | ||
RGB = "RGB", | ||
RGBA = "RGBA", | ||
ARGB = "ARGB", | ||
BGR = "BGR", | ||
BGRA = "BGRA", | ||
ABGR = "ABGR", | ||
GBR = "GBR", | ||
GBRA = "GBRA", | ||
AGBR = "AGBR", | ||
GRB = "GRB", | ||
GRBA = "GRBA", | ||
AGRB = "AGRB" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters