Introduction
Contains a color which can be used to draw on a GD2 image.
BCGColor's Methods
- __construct(...) — Construct the BCGColor class
- setTransparent($transparent) — Sets the color to be transparent
- r() — Returns the red component
- g() — Returns the green component
- b() — Returns the blue component
- allocate($im) — Allocates the color on the image
- getColor($code, $default = 'white') — Gets the color from text
Code Example
// To get an example on how to use this class, check barcode classes. Methods Explanation
-
__construct(...)
— Construct the BCGColor class DescriptionBy creating this class, you must specify which color will be contained within the class. You can do this in different ways:
- Give 3 integers, the arguments must be in this order: red, green, and blue. The numbers must be between 0 and 255.
- Give 1 string with hexadecimal form with the pound character (#). Example: #ff0000
- Give 1 integer with hexadecimal format. Example: 0xff0000
- Give 1 string with the color code (white, black, orange...). See getText().
-
setTransparent($transparent)
— Sets the color to be transparent DescriptionSpecify the color to be transparent. Please note that any other BCGColor carrying the same color code will be also transparent.
Use this method only once per drawing, otherwise result could be unexpected. -
r()
— Returns the red component DescriptionThe red component used in the color.Returnsint - value between 0 and 255
-
g()
— Returns the green component DescriptionThe green component used in the color.Returnsint - value between 0 and 255
-
b()
— Returns the blue component DescriptionThe blue component used in the color.Returnsint - value between 0 and 255
-
allocate($im)
— Allocates the color on the image DescriptionAllocates the color on the image $im and will call imagecolorallocate function from PHP.Returnsint - PHP resource
-
getColor($code, $default = 'white')
— Gets the color from text DescriptionStatic method returns an integer depending on the color code. Here the accepted codes:
- white
- black
- maroon
- red
- orange
- yellow
- olive
- purple
- fuchsia
- lime
- green
- navy
- blue
- aqua
- teal
- silver
- gray
Returnsstring
