|
@@ -68,8 +68,8 @@ discard block |
|
|
block discarded – undo |
68
|
68
|
foreach($row as $c => $pixel){ |
69
|
69
|
if($pixel){ |
70
|
70
|
imagefilledrectangle($image, |
71
|
|
- $this->options->marginSize + $c * $this->options->pixelSize, |
72
|
|
- $this->options->marginSize + $r * $this->options->pixelSize, |
|
71
|
+ $this->options->marginSize + $c * $this->options->pixelSize, |
|
72
|
+ $this->options->marginSize + $r * $this->options->pixelSize, |
73
|
73
|
$this->options->marginSize + ($c + 1) * $this->options->pixelSize - 1, |
74
|
74
|
$this->options->marginSize + ($r + 1) * $this->options->pixelSize - 1, |
75
|
75
|
$foreground); |
|
@@ -122,16 +122,16 @@ discard block |
|
|
block discarded – undo |
122
|
122
|
*/ |
123
|
123
|
protected function toSVG(){ |
124
|
124
|
$length = $this->pixelCount * $this->options->pixelSize + $this->options->marginSize * 2; |
125
|
|
- $class = 'f' . hash('crc32', microtime(true)); |
126
|
|
- $foreground = 'rgb(' . $this->options->fgRed . ',' . $this->options->fgGreen . ',' . $this->options->fgBlue . ')'; |
|
125
|
+ $class = 'f'.hash('crc32', microtime(true)); |
|
126
|
+ $foreground = 'rgb('.$this->options->fgRed.','.$this->options->fgGreen.','.$this->options->fgBlue.')'; |
127
|
127
|
$background = (bool)$this->options->transparent |
128
|
128
|
? 'transparent' |
129
|
|
- : 'rgb(' . $this->options->bgRed . ',' . $this->options->bgGreen . ',' . $this->options->bgBlue . ')'; |
|
129
|
+ : 'rgb('.$this->options->bgRed.','.$this->options->bgGreen.','.$this->options->bgBlue.')'; |
130
|
130
|
|
131
|
131
|
ob_start(); |
132
|
132
|
|
133
|
133
|
// svg header |
134
|
|
- echo '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="' . $length . '" height="' . $length . '" viewBox="0 0 ' . $length . ' ' . $length . '" style="background-color:' . $background . '"><defs><style>.' . $class . '{fill:' . $foreground . '} rect{shape-rendering:crispEdges}</style></defs>'; |
|
134
|
+ echo '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'.$length.'" height="'.$length.'" viewBox="0 0 '.$length.' '.$length.'" style="background-color:'.$background.'"><defs><style>.'.$class.'{fill:'.$foreground.'} rect{shape-rendering:crispEdges}</style></defs>'; |
135
|
135
|
|
136
|
136
|
// svg body |
137
|
137
|
foreach($this->matrix AS $r=>$row){ |
|
@@ -146,7 +146,7 @@ discard block |
|
|
block discarded – undo |
146
|
146
|
$from = $c; |
147
|
147
|
} |
148
|
148
|
else if($from >= 0){ |
149
|
|
- echo '<rect x="' . ($from * $this->options->pixelSize + $this->options->marginSize) . '" y="' . ($r * $this->options->pixelSize + $this->options->marginSize) . '" width="' . ($this->options->pixelSize * $count) . '" height="' . $this->options->pixelSize . '" class="' . $class . '" />'; |
|
149
|
+ echo '<rect x="'.($from * $this->options->pixelSize + $this->options->marginSize).'" y="'.($r * $this->options->pixelSize + $this->options->marginSize).'" width="'.($this->options->pixelSize * $count).'" height="'.$this->options->pixelSize.'" class="'.$class.'" />'; |
150
|
150
|
|
151
|
151
|
// reset count |
152
|
152
|
$from = -1; |
|
@@ -156,7 +156,7 @@ discard block |
|
|
block discarded – undo |
156
|
156
|
|
157
|
157
|
// close off the row, if applicable |
158
|
158
|
if($from >= 0){ |
159
|
|
- echo '<rect x="' . ($from * $this->options->pixelSize + $this->options->marginSize) . '" y="' . ($r * $this->options->pixelSize + $this->options->marginSize) . '" width="' . ($this->options->pixelSize * $count) . '" height="' . $this->options->pixelSize . '" class="' . $class . '" />'; |
|
159
|
+ echo '<rect x="'.($from * $this->options->pixelSize + $this->options->marginSize).'" y="'.($r * $this->options->pixelSize + $this->options->marginSize).'" width="'.($this->options->pixelSize * $count).'" height="'.$this->options->pixelSize.'" class="'.$class.'" />'; |
160
|
160
|
} |
161
|
161
|
} |
162
|
162
|
|
|
@@ -166,7 +166,7 @@ discard block |
|
|
block discarded – undo |
166
|
166
|
|
167
|
167
|
// if saving to file, append the correct headers |
168
|
168
|
if($this->options->cachefile){ |
169
|
|
- @file_put_contents($this->options->cachefile, '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n" . $imageData); |
|
169
|
+ @file_put_contents($this->options->cachefile, '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n".$imageData); |
170
|
170
|
} |
171
|
171
|
|
172
|
172
|
if((bool)$this->options->base64){ |