GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
Color Class Reference

Public Member Functions

 __construct ($r, $g, $b)
 
 getRed ()
 
 getBlue ()
 
 getGreen ()
 
 getColorCode ()
 
 __toString ()
 

Static Public Member Functions

static init ()
 
static getRGB ($r, $g, $b)
 
static averageColor (Color ... $colors)
 
static getDyeColor ($id)
 

Data Fields

const COLOR_DYE_BLACK = 0
 
const COLOR_DYE_RED = 1
 
const COLOR_DYE_GREEN = 2
 
const COLOR_DYE_BROWN = 3
 
const COLOR_DYE_BLUE = 4
 
const COLOR_DYE_PURPLE = 5
 
const COLOR_DYE_CYAN = 6
 
const COLOR_DYE_LIGHT_GRAY = 7
 
const COLOR_DYE_GRAY = 8
 
const COLOR_DYE_PINK = 9
 
const COLOR_DYE_LIME = 10
 
const COLOR_DYE_YELLOW = 11
 
const COLOR_DYE_LIGHT_BLUE = 12
 
const COLOR_DYE_MAGENTA = 13
 
const COLOR_DYE_ORANGE = 14
 
const COLOR_DYE_WHITE = 15
 

Static Public Attributes

static $dyeColors = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $r,
  $g,
  $b 
)

Color constructor.

Parameters
$r
$g
$b
125  {
126  $this->red = $r;
127  $this->green = $g;
128  $this->blue = $b;
129  }

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string
162  {
163  return "Color(red:" . $this->red . ", green:" . $this->green . ", blue:" . $this->blue . ")";
164  }

◆ averageColor()

static averageColor ( Color ...  $colors)
static
Parameters
Color[]...$colors
Returns
Color
92  {
93  $tr = 0;//total red
94  $tg = 0;//green
95  $tb = 0;//blue
96  $count = 0;
97  foreach($colors as $c){
98  $tr += $c->getRed();
99  $tg += $c->getGreen();
100  $tb += $c->getBlue();
101  ++$count;
102  }
103  return Color::getRGB($tr / $count, $tg / $count, $tb / $count);
104  }

◆ getBlue()

getBlue ( )
Returns
int
141  {
142  return (int) $this->blue;
143  }

◆ getColorCode()

getColorCode ( )
Returns
int
155  {
156  return ($this->red << 16 | $this->green << 8 | $this->blue) & 0xffffff;
157  }

◆ getDyeColor()

static getDyeColor (   $id)
static
Parameters
$id
Returns
mixed|Color
111  {
112  if(isset(self::$dyeColors[$id])){
113  return clone self::$dyeColors[$id];
114  }
115  return Color::getRGB(0, 0, 0);
116  }

◆ getGreen()

getGreen ( )
Returns
int
148  {
149  return (int) $this->green;
150  }

◆ getRed()

getRed ( )
Returns
int
134  {
135  return (int) $this->red;
136  }

◆ getRGB()

static getRGB (   $r,
  $g,
  $b 
)
static
Parameters
$r
$g
$b
Returns
Color
83  {
84  return new Color((int) $r, (int) $g, (int) $b);
85  }

◆ init()

static init ( )
static
54  {
55  if(self::$dyeColors === null){
56  self::$dyeColors = new \SplFixedArray(16); //What's the point of making a 256-long array for 16 objects?
57  self::$dyeColors[self::COLOR_DYE_BLACK] = Color::getRGB(30, 27, 27);
58  self::$dyeColors[self::COLOR_DYE_RED] = Color::getRGB(179, 49, 44);
59  self::$dyeColors[self::COLOR_DYE_GREEN] = Color::getRGB(61, 81, 26);
60  self::$dyeColors[self::COLOR_DYE_BROWN] = Color::getRGB(81, 48, 26);
61  self::$dyeColors[self::COLOR_DYE_BLUE] = Color::getRGB(37, 49, 146);
62  self::$dyeColors[self::COLOR_DYE_PURPLE] = Color::getRGB(123, 47, 190);
63  self::$dyeColors[self::COLOR_DYE_CYAN] = Color::getRGB(40, 118, 151);
64  self::$dyeColors[self::COLOR_DYE_LIGHT_GRAY] = Color::getRGB(153, 153, 153);
65  self::$dyeColors[self::COLOR_DYE_GRAY] = Color::getRGB(67, 67, 67);
66  self::$dyeColors[self::COLOR_DYE_PINK] = Color::getRGB(216, 129, 152);
67  self::$dyeColors[self::COLOR_DYE_LIME] = Color::getRGB(65, 205, 52);
68  self::$dyeColors[self::COLOR_DYE_YELLOW] = Color::getRGB(222, 207, 42);
69  self::$dyeColors[self::COLOR_DYE_LIGHT_BLUE] = Color::getRGB(102, 137, 211);
70  self::$dyeColors[self::COLOR_DYE_MAGENTA] = Color::getRGB(195, 84, 205);
71  self::$dyeColors[self::COLOR_DYE_ORANGE] = Color::getRGB(235, 136, 68);
72  self::$dyeColors[self::COLOR_DYE_WHITE] = Color::getRGB(240, 240, 240);
73  }
74  }

Field Documentation

◆ $dyeColors

$dyeColors = null
static

◆ COLOR_DYE_BLACK

const COLOR_DYE_BLACK = 0

◆ COLOR_DYE_BLUE

const COLOR_DYE_BLUE = 4

◆ COLOR_DYE_BROWN

const COLOR_DYE_BROWN = 3

◆ COLOR_DYE_CYAN

const COLOR_DYE_CYAN = 6

◆ COLOR_DYE_GRAY

const COLOR_DYE_GRAY = 8

◆ COLOR_DYE_GREEN

const COLOR_DYE_GREEN = 2

◆ COLOR_DYE_LIGHT_BLUE

const COLOR_DYE_LIGHT_BLUE = 12

◆ COLOR_DYE_LIGHT_GRAY

const COLOR_DYE_LIGHT_GRAY = 7

◆ COLOR_DYE_LIME

const COLOR_DYE_LIME = 10

◆ COLOR_DYE_MAGENTA

const COLOR_DYE_MAGENTA = 13

◆ COLOR_DYE_ORANGE

const COLOR_DYE_ORANGE = 14

◆ COLOR_DYE_PINK

const COLOR_DYE_PINK = 9

◆ COLOR_DYE_PURPLE

const COLOR_DYE_PURPLE = 5

◆ COLOR_DYE_RED

const COLOR_DYE_RED = 1

◆ COLOR_DYE_WHITE

const COLOR_DYE_WHITE = 15

◆ COLOR_DYE_YELLOW

const COLOR_DYE_YELLOW = 11

The documentation for this class was generated from the following file: