allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
39
vendor/ageekdev/laravel-barcode/src/Drivers/HTML.php
vendored
Normal file
39
vendor/ageekdev/laravel-barcode/src/Drivers/HTML.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace AgeekDev\Barcode\Drivers;
|
||||
|
||||
use AgeekDev\Barcode\AbstractGenerator;
|
||||
use AgeekDev\Barcode\BarcodeBar;
|
||||
|
||||
class HTML extends AbstractGenerator
|
||||
{
|
||||
/**
|
||||
* Return an HTML representation of barcode.
|
||||
* This original version uses pixel based widths and heights. Use Dynamic HTML version for better quality representation.
|
||||
*/
|
||||
public function generate(string $text): string
|
||||
{
|
||||
$barcodeData = $this->getBarcodeData($text, $this->type);
|
||||
|
||||
$html = '<div style="font-size:0;position:relative;width:'.($barcodeData->getWidth() * $this->widthFactor).'px;height:'.($this->height).'px;">'.PHP_EOL;
|
||||
|
||||
$positionHorizontal = 0;
|
||||
/** @var BarcodeBar $bar */
|
||||
foreach ($barcodeData->getBars() as $bar) {
|
||||
$barWidth = round(($bar->getWidth() * $this->widthFactor), 3);
|
||||
$barHeight = round(($bar->getHeight() * $this->height / $barcodeData->getHeight()), 3);
|
||||
|
||||
if ($barWidth > 0 && $bar->isBar()) {
|
||||
$positionVertical = round(($bar->getPositionVertical() * $this->height / $barcodeData->getHeight()), 3);
|
||||
|
||||
$html .= '<div style="background-color:'.$this->foregroundColor.';width:'.$barWidth.'px;height:'.$barHeight.'px;position:absolute;left:'.$positionHorizontal.'px;top:'.$positionVertical.(($positionVertical > 0) ? 'px' : '').'"> </div>'.PHP_EOL;
|
||||
}
|
||||
|
||||
$positionHorizontal += $barWidth;
|
||||
}
|
||||
|
||||
$html .= '</div>'.PHP_EOL;
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user