1111
1212namespace chillerlan \QRCode \Output ;
1313
14- use function array_chunk , implode , is_string , preg_match , sprintf , trim ;
14+ use chillerlan \QRCode \Data \QRMatrix ;
15+ use function array_any , array_chunk , implode , is_string , preg_match , sprintf , trim ;
1516
1617/**
1718 * SVG output
@@ -28,9 +29,13 @@ class QRMarkupSVG extends QRMarkup{
2829
2930 final public const string MIME_TYPE = 'image/svg+xml ' ;
3031
31- // micro optimization for circle radius and diameter values in long loops
32+ // micro optimization for QROptions values in long loops
3233 protected float $ r ;
3334 protected float $ d ;
35+ protected bool $ drawLightModules ;
36+ protected bool $ drawCircularModules ;
37+ protected array $ keepAsSquare ;
38+
3439
3540 /**
3641 * @todo: XSS proof
@@ -68,6 +73,12 @@ protected function getCssClass(int $M_TYPE = 0):string{
6873 }
6974
7075 protected function createMarkup (bool $ saveToFile ):string {
76+ $ this ->r = $ this ->options ->circleRadius ;
77+ $ this ->d = ($ this ->r * 2 );
78+ $ this ->drawCircularModules = $ this ->options ->drawCircularModules ;
79+ $ this ->drawLightModules = $ this ->options ->drawLightModules ;
80+ $ this ->keepAsSquare = $ this ->options ->keepAsSquare ;
81+
7182 $ svg = $ this ->header ();
7283
7384 if ($ this ->options ->svgDefs !== '' ){
@@ -120,9 +131,6 @@ protected function header():string{
120131 * returns one or more SVG <path> elements
121132 */
122133 protected function paths ():string {
123- $ this ->r = $ this ->options ->circleRadius ;
124- $ this ->d = ($ this ->r * 2 );
125-
126134 $ paths = $ this ->collectModules ();
127135 $ svg = [];
128136
@@ -174,11 +182,11 @@ protected function path(string $path, int $M_TYPE):string{
174182 */
175183 protected function moduleTransform (int $ x , int $ y , int $ M_TYPE , int $ M_TYPE_LAYER ):string |null {
176184
177- if (!$ this ->options -> drawLightModules && !$ this -> matrix -> isDark ( $ M_TYPE )){
185+ if (!$ this ->drawLightModules && !(( $ M_TYPE & QRMatrix:: IS_DARK ) === QRMatrix:: IS_DARK )){
178186 return null ;
179187 }
180188
181- if ($ this ->options -> drawCircularModules && !$ this ->matrix -> checkTypeIn ( $ x , $ y , $ this -> options -> keepAsSquare )){
189+ if ($ this ->drawCircularModules && !array_any ( $ this ->keepAsSquare , fn ( $ type ) => ( $ M_TYPE & $ type ) === $ type )){
182190 // string interpolation: ugly and fast
183191 $ ix = ($ x + 0.5 - $ this ->r );
184192 $ iy = ($ y + 0.5 );
0 commit comments