1# Drawing a barcode 39 2 3[Reference](http://wiki.pchart.net/doc.barcode39.pBarcode39.html) 4 5```php 6require '/path/to/your/vendor/autoload.php'; 7 8use CpChart\Barcode\Barcode39; 9use CpChart\Image; 10 11/* Create the Image object */ 12$image = new Image(700, 230); 13 14/* Draw the background */ 15$image->drawFilledRectangle(0, 0, 700, 230, [ 16 "R" => 170, 17 "G" => 183, 18 "B" => 87, 19 "Dash" => 1, 20 "DashR" => 190, 21 "DashG" => 203, 22 "DashB" => 107 23]); 24 25/* Overlay with a gradient */ 26$image->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, [ 27 "StartR" => 219, 28 "StartG" => 231, 29 "StartB" => 139, 30 "EndR" => 1, 31 "EndG" => 138, 32 "EndB" => 68, 33 "Alpha" => 50 34]); 35$image->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, [ 36 "StartR" => 0, 37 "StartG" => 0, 38 "StartB" => 0, 39 "EndR" => 50, 40 "EndG" => 50, 41 "EndB" => 50, 42 "Alpha" => 80 43]); 44 45/* Draw the picture border */ 46$image->drawRectangle(0, 0, 699, 229, ["R" => 0, "G" => 0, "B" => 0]); 47 48/* Write the title */ 49$image->setFontProperties(["FontName" => "Silkscreen.ttf", "FontSize" => 6]); 50$image->drawText(10, 13, "Barcode 39 - Add barcode to your pictures", ["R" => 255, "G" => 255, "B" => 255]); 51 52/* Create the barcode 39 object */ 53$barcodeChart = new Barcode39(); 54 55/* Draw a simple barcode */ 56$image->setFontProperties(["FontName" => "pf_arma_five.ttf", "FontSize" => 6]); 57$barcodeChart->draw($image, "pChart Rocks!", 50, 50, ["ShowLegend" => true, "DrawArea" => true]); 58 59/* Draw a rotated barcode */ 60$image->setFontProperties(["FontName" => "Forgotte.ttf", "FontSize" => 12]); 61$barcodeChart->draw($image, "Turn me on", 650, 50, ["ShowLegend" => true, "DrawArea" => true, "Angle" => 90]); 62 63/* Draw a rotated barcode */ 64$image->setFontProperties(["FontName" => "Forgotte.ttf", "FontSize" => 12]); 65$barcodeChart->draw($image, "Do what you want !", 290, 140, [ 66 "R" => 255, 67 "G" => 255, 68 "B" => 255, 69 "AreaR" => 150, 70 "AreaG" => 30, 71 "AreaB" => 27, 72 "ShowLegend" => true, 73 "DrawArea" => true, 74 "Angle" => 350, 75 "AreaBorderR" => 70, 76 "AreaBorderG" => 20, 77 "AreaBorderB" => 20 78]); 79 80/* Render the picture (choose the best way) */ 81$image->autoOutput("example.barcode39.png"); 82``` 83