Manual - Color
Introduction
Contains a color which can be used to draw on an image resource.
Methods
BCGColor's Methods
-
__constructor__(
... ) — 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 ,defaultColor ) — Gets the color from text
Code Example
// To get an example on how to use this class, check barcode classes.
Method explanations
-
__constructor__(
... ) — Construct the BCGColor classDescriptionBy 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...). SeegetColor() . -
setTransparent(
transparent ) — Sets the color to be transparentDescriptionSpecify 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.Returns
int - value between 0 and 255 -
g()
—
Returns the green component
DescriptionThe green component used in the color.Returns
int - value between 0 and 255 -
b()
—
Returns the blue component
DescriptionThe blue component used in the color.Returns
int - value between 0 and 255 -
allocate(
im ) — Allocates the color on the imageDescriptionAllocates the color on the imageimage and will call imagecolorallocate function from PHP.Returnsint - PHP resource -
getColor(
code ,defaultColor ) — Gets the color from textDescriptionStatic 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
If a color doesn't exist, it is passed to this method. The colordefault is used. This color is white by default.Returnsint