Manual - Barcode 2D
Introduction
This class is an abstract class that contains the base methods to create 2D barcodes only.
This class inherits the BCGBarcode class.
Methods
BCGBarcode2D's Methods
-
setScaleX(
$scaleX ) — Sets the scaling X for the barcode -
setScaleY(
$scaleY ) — Sets the scaling Y for the barcode
BCGBarcode's Methods
-
parse(
$text ) — Analyzes a$text message to draw afterwards -
draw(
$image ) — Draws the barcode on the$image -
getDimension(
$width ,$height ) — Returns an array containing the required size for the image - getScale() — Gets the scale of the barcode
-
setScale(
$scale ) — Sets the scale of the barcode - getForegroundColor() — Gets the color of the bars
-
setForegroundColor(
$color ) — Sets the color of the bars - getBackgroundColor() — Gets the color of the spaces
-
setBackgroundColor(
$color ) — Sets the color of the spaces -
setColor(
$foregroundColor ,$backgroundColor ) — Sets the color of the bars and spaces - getOffsetX() — Gets the X offset
-
setOffsetX(
$value ) — Sets the X offset - getOffsetY() — Gets the Y offset
-
setOffsetY(
$value ) — Sets the Y offset -
addLabel(
$label ) — Adds a label to the graphic -
removeLabel(
$label ) — Removes a label from the graphic - clearLabels() — Removes the labels from the graphic
Code Example
// To get an example on how to use this class, check barcode classes.
Method explanations
-
setScaleX(
$scaleX ) — Sets the scaling X for the barcodeDescriptionThe width in pixel of one module.
The default value is 1.
Note that this method is protected. -
setScaleY(
$scaleY ) — Sets the scaling Y for the barcodeDescriptionThe height in pixel of one module.
The default value is 1.
Note that this method is protected.
-
parse(
$text ) — Analyzes a$text message to draw afterwardsDescriptionThe data you pass to the$text argument must be supported by the type of barcode you use.
Check each barcode's introduction section to obtain more information on how to use this method within each symbology. -
draw(
$image ) — Draws the barcode on the$image DescriptionThe value of the$image argument must be an image resource. The size of the image can be defined by the value received fromgetDimension() . -
getDimension(
$width ,$height ) — Returns an array containing the required size for the imageDescriptionReturns an array in which the first index is the image width and the second index is the image height.
The arguments are used to specify the starting point of the drawing. Should be 0 for both.
TheBCGDrawing class uses this method to create the image resource.Returnsarray(int, int) - [0] is the width, [1] is the height -
getScale()
—
Gets the scale of the barcode
DescriptionGets the scale of the barcode. The value is the number of the "smallest" unit in pixel.Returns
int - value in pixels -
setScale(
$scale ) — Sets the scale of the barcodeDescriptionThe barcode will be$x times bigger. Then a pixel will be$x by$x for its size. -
getForegroundColor()
—
Gets the color of the bars
DescriptionGets the color of the bars of the barcode.Returns
-
setForegroundColor(
$color ) — Sets the color of the bars -
getBackgroundColor()
—
Gets the color of the spaces
DescriptionGets the color of the spaces of the barcode.Returns
-
setBackgroundColor(
$color ) — Sets the color of the spaces -
setColor(
$foregroundColor ,$backgroundColor ) — Sets the color of the bars and spacesDescriptionAn easy and fast method to set the color of the bars and spaces. Check thesetForegroundColor() andsetBackgroundColor() . -
getOffsetX()
—
Gets the X offset
DescriptionGets the X offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
setOffsetX(
$value ) — Sets the X offsetDescriptionSpecifies the X offset of the barcode in pixels multiplied by the scale. The required size returned bygetDimension() will be modified accordingly. -
getOffsetY()
—
Gets the Y offset
DescriptionGets the Y offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
setOffsetY(
$value ) — Sets the Y offsetDescriptionSpecifies the Y offset of the barcode in pixels multiplied by the scale. The required size returned bygetDimension() will be modified accordingly. -
addLabel(
$label ) — Adds a label to the graphicDescriptionAdds aBCGLabel object to the drawing. -
removeLabel(
$label ) — Removes a label from the graphicDescriptionRemoves a specificBCGLabel object from the drawing. -
clearLabels()
—
Removes the labels from the graphic
DescriptionClears the
BCGLabel objects from the drawing.