From 26e9a5945c14c998156cc4629bccae898b285410 Mon Sep 17 00:00:00 2001 From: "Rebecca G. Bettencourt" Date: Tue, 21 Jun 2016 19:01:38 -0700 Subject: [PATCH] Tweak default scale and padding for matrix barcodes. --- README.md | 4 +-- barcode-qr-test.html | 72 ++++++++++++++++++++++---------------------- barcode-readme.html | 10 ++++-- barcode.php | 6 ++-- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 58615d0..39ef4c2 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,13 @@ barcode.php?f=svg&s=qr&d=HELLO%20WORLD&sf=8&ms=r&md=0.8 `h` - Height of image. Overrides `sf` or `sy`. -`sf` - Scale factor. +`sf` - Scale factor. Default is 1 for linear barcodes or 4 for matrix barcodes. `sx` - Horizontal scale factor. Overrides `sf`. `sy` - Vertical scale factor. Overrides `sf`. -`p` - Padding. Default is 10. +`p` - Padding. Default is 10 for linear barcodes or 0 for matrix barcodes. `pv` - Top and bottom padding. Default is value of `p`. diff --git a/barcode-qr-test.html b/barcode-qr-test.html index 23169f3..243e3e6 100644 --- a/barcode-qr-test.html +++ b/barcode-qr-test.html @@ -11,58 +11,58 @@

Jenny doesn't live here anymore.

-

-

-

-

+

+

+

+

Hello.

-

-

-

-

+

+

+

+

Hello again.

-

-

-

-

+

+

+

+

Almost, but not quite, entirely unlike tea.

-

-

-

-

+

+

+

+

Full of sound and fury, signifying nothing.

-

-

-

-

+

+

+

+

Mmm, pie.

-

-

-

-

+

+

+

+

Make it stop!

-

-

-

-

+

+

+

+

Make it stop!

-

-

-

-

+

+

+

+

All the tea in China.

-

-

-

-

+

+

+

+

\ No newline at end of file diff --git a/barcode-readme.html b/barcode-readme.html index b26db94..a9b6cb1 100644 --- a/barcode-readme.html +++ b/barcode-readme.html @@ -117,7 +117,10 @@ barcode.php?f=svg&s=qr&d=HELLO%20WORLD&sf=8&ms=r&md=0.8 sf - Scale factor. + + Scale factor. + Default is 1 for linear barcodes or 4 for matrix barcodes. + sx @@ -129,7 +132,10 @@ barcode.php?f=svg&s=qr&d=HELLO%20WORLD&sf=8&ms=r&md=0.8 p - Padding. Default is 10. + + Padding. + Default is 10 for linear barcodes or 0 for matrix barcodes. + pv diff --git a/barcode.php b/barcode.php index a613f8f..ee57b6d 100644 --- a/barcode.php +++ b/barcode.php @@ -148,10 +148,12 @@ class barcode_generator { (isset($options['w9']) ? (int)$options['w9'] : 1), ); $size = $this->dispatch_calculate_size($code, $widths, $options); - $scale = (isset($options['sf']) ? (float)$options['sf'] : 1); + $dscale = ($code && isset($code['g']) && $code['g'] == 'm') ? 4 : 1; + $scale = (isset($options['sf']) ? (float)$options['sf'] : $dscale); $scalex = (isset($options['sx']) ? (float)$options['sx'] : $scale); $scaley = (isset($options['sy']) ? (float)$options['sy'] : $scale); - $padding = (isset($options['p']) ? (int)$options['p'] : 10); + $dpadding = ($code && isset($code['g']) && $code['g'] == 'm') ? 0 : 10; + $padding = (isset($options['p']) ? (int)$options['p'] : $dpadding); $vert = (isset($options['pv']) ? (int)$options['pv'] : $padding); $horiz = (isset($options['ph']) ? (int)$options['ph'] : $padding); $top = (isset($options['pt']) ? (int)$options['pt'] : $vert);