Manual - Color

Introduction

Contains a color which can be used to draw on an image resource.

Methods

BCGColor's Methods

Code Example


// To get an example on how to use this class, check barcode classes.

Method explanations

  • __constructor__( ...) — Construct the BCGColor class
    Description
    By 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 GetColor().
  • SetTransparent(bool transparent) — Sets the color to be transparent
    Description
    Specify 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
    Description
    The red component used in the color.
    Returns
    int - value between 0 and 255
  • G() — Returns the green component
    Description
    The green component used in the color.
    Returns
    int - value between 0 and 255
  • B() — Returns the blue component
    Description
    The blue component used in the color.
    Returns
    int - value between 0 and 255
  • Allocate(Graphics im) — Allocates the color on the image
    Description
    Allocates the color on the image image and will call imagecolorallocate function from PHP.
    Returns
    int - PHP resource
  • GetColor(string code, string defaultColor) — Gets the color from text
    Description
    Static 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 color default is used. This color is white by default.
    Returns
    int