35 lines
689 B
PHP
35 lines
689 B
PHP
|
<?php
|
||
|
// ColourRGB.php
|
||
|
// Created: 2021-09-09
|
||
|
// Updated: 2021-09-09
|
||
|
|
||
|
namespace Index;
|
||
|
|
||
|
class ColourRGB extends Colour {
|
||
|
protected int $raw;
|
||
|
|
||
|
public function __construct(int $raw) {
|
||
|
$this->raw = $raw;
|
||
|
}
|
||
|
|
||
|
public function getRaw(): int {
|
||
|
return $this->raw;
|
||
|
}
|
||
|
|
||
|
public function getRed(): int {
|
||
|
return ($this->raw >> 16) & 0xFF;
|
||
|
}
|
||
|
|
||
|
public function getGreen(): int {
|
||
|
return ($this->raw >> 8) & 0xFF;
|
||
|
}
|
||
|
|
||
|
public function getBlue(): int {
|
||
|
return $this->raw & 0xFF;
|
||
|
}
|
||
|
|
||
|
public function toString(): IString {
|
||
|
return new AString('#' . str_pad(dechex($this->raw & 0xFFFFFF), 6, '0', STR_PAD_LEFT));
|
||
|
}
|
||
|
}
|