• Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/barcode/barcodegenerator.php
  • Класс: BitrixUIBarcodeBarcodeGenerator
  • Вызов: BarcodeGenerator::matrix_render_svg
private function matrix_render_svg(
	$code, $x, $y, $w, $h, $colors, $widths, $options
) {
	$shape = (isset($options['ms']) ? strtolower($options['ms']) : '');
	$density = (isset($options['md']) ? (float)$options['md'] : 1);
	list($width, $height) = $this->matrix_calculate_size($code, $widths);
	if ($width && $height) {
		$scale = min($w / $width, $h / $height);
		if ($scale > 1) $scale = floor($scale);
		$x = floor($x + ($w - $width * $scale) / 2);
		$y = floor($y + ($h - $height * $scale) / 2);
	} else {
		$scale = 1;
		$x = floor($x + $w / 2);
		$y = floor($y + $h / 2);
	}
	$tx = 'translate(' . $x . ' ' . $y . ')';
	if ($scale != 1) $tx .= ' scale(' . $scale . ' ' . $scale . ')';
	$svg = '';
	$x = $code['q'][3] * $widths[0];
	$y = $code['q'][0] * $widths[0];
	$wh = $widths[1];
	foreach ($code['b'] as $by => $row) {
		$y1 = $y + $by * $wh;
		foreach ($row as $bx => $color) {
			$x1 = $x + $bx * $wh;
			$mc = $colors[$color];
			if ($mc) {
				$svg .= $this->matrix_dot_svg(
					$x1, $y1, $wh, $wh, $mc, $shape, $density
				);
			}
		}
	}
	return $svg . '';
}