smiley 2 年 前
コミット
15dcc0195f
2 ファイル変更10 行追加10 行削除
  1. 7 7
      examples/svg.php
  2. 3 3
      src/Data/Number.php

+ 7 - 7
examples/svg.php

@@ -40,13 +40,13 @@ $options = new QROptions([
 	],
 	// https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
 	'svgDefs'             => '
-	<linearGradient id="rainbow" x1="100%" y2="100%">
-		<stop stop-color="#e2453c" offset="2.5%"/>
-		<stop stop-color="#e07e39" offset="21.5%"/>
-		<stop stop-color="#e5d667" offset="40.5%"/>
-		<stop stop-color="#51b95b" offset="59.5%"/>
-		<stop stop-color="#1e72b7" offset="78.5%"/>
-		<stop stop-color="#6f5ba7" offset="97.5%"/>
+	<linearGradient id="rainbow" x1="1" y2="1">
+		<stop stop-color="#e2453c" offset="0"/>
+		<stop stop-color="#e07e39" offset="0.2"/>
+		<stop stop-color="#e5d667" offset="0.4"/>
+		<stop stop-color="#51b95b" offset="0.6"/>
+		<stop stop-color="#1e72b7" offset="0.8"/>
+		<stop stop-color="#6f5ba7" offset="1"/>
 	</linearGradient>
 	<style><![CDATA[
 		.dark{fill: url(#rainbow);}

+ 3 - 3
src/Data/Number.php

@@ -12,7 +12,7 @@ namespace chillerlan\QRCode\Data;
 
 use chillerlan\QRCode\Common\{BitBuffer, Mode};
 
-use function array_flip, ceil, ord, str_split, substr;
+use function array_flip, ceil, str_split, substr, unpack;
 
 /**
  * Numeric mode: decimal digits 0 to 9
@@ -100,8 +100,8 @@ final class Number extends QRDataModeAbstract{
 	private function parseInt(string $string):int{
 		$num = 0;
 
-		foreach(str_split($string) as $chr){
-			$num = ($num * 10 + ord($chr) - 48);
+		foreach(unpack('C*', $string) as $chr){
+			$num = ($num * 10 + $chr - 48);
 		}
 
 		return $num;