diagrams-qrcode 1.2 → 1.3
raw patch · 4 files changed
+19/−14 lines, 4 filesdep ~basedep ~diagrams-coredep ~diagrams-libPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, diagrams-core, diagrams-lib
API changes (from Hackage documentation)
- Diagrams.QRCode: pathArray :: (Bounded a, Eq a, Integral ix, Ix ix) => Array (ix, ix) a -> Path R2
+ Diagrams.QRCode: pathArray :: (Bounded a, Eq a, Integral ix, Ix ix) => Array (ix, ix) a -> Path V2 Double
- Diagrams.QRCode: pathList :: (Bounded a, Eq a, Integral ix) => [((ix, ix), a)] -> Path R2
+ Diagrams.QRCode: pathList :: (Bounded a, Eq a, Integral ix) => [((ix, ix), a)] -> Path V2 Double
- Diagrams.QRCode: pathMatrix :: (Bounded a, Eq a) => [[a]] -> Path R2
+ Diagrams.QRCode: pathMatrix :: (Bounded a, Eq a) => [[a]] -> Path V2 Double
- Diagrams.QRCode: stroke :: (Backend b R2, Renderable (Path R2) b) => Path R2 -> Diagram b R2
+ Diagrams.QRCode: stroke :: (Backend b V2 Double, Renderable (Path V2 Double) b) => Path V2 Double -> QDiagram b V2 Double Any
Files
- diagrams-qrcode.cabal +4/−4
- examples/using-haskell-qrencode.hs +3/−2
- examples/using-qrcode.hs +3/−2
- src/Diagrams/QRCode.hs +9/−6
diagrams-qrcode.cabal view
@@ -1,5 +1,5 @@ name: diagrams-qrcode-version: 1.2+version: 1.3 synopsis: Draw QR codes to SVG, PNG, PDF or PS files. homepage: https://github.com/prowdsponsor/diagrams-qrcode license: BSD3@@ -37,10 +37,10 @@ exposed-modules: Diagrams.QRCode build-depends:- base >= 4.5 && < 4.8+ base >= 4.5 && < 4.9 , array , colour- , diagrams-core == 1.2.*- , diagrams-lib == 1.2.*+ , diagrams-core == 1.3.*+ , diagrams-lib == 1.3.* hs-source-dirs: src/ ghc-options: -Wall
examples/using-haskell-qrencode.hs view
@@ -1,4 +1,5 @@-import Text.Blaze.Svg.Renderer.Utf8 (renderSvg) -- blaze-svg+{-# LANGUAGE OverloadedStrings #-}+import Lucid.Svg (renderBS) -- lucid-svg import qualified Data.ByteString.Lazy.Char8 as L8 -- bytestring import qualified Data.QRCode as QR -- haskell-qrencode import qualified Diagrams.Backend.SVG as D -- diagrams-svg@@ -17,4 +18,4 @@ let dia = D.scale 6 $ QR.stroke $ QR.pathMatrix $ QR.toMatrix qrcode -- Render diagram- L8.putStrLn $ renderSvg $ D.renderDia D.SVG (D.SVGOptions D.Absolute Nothing) dia+ L8.putStrLn $ renderBS $ D.renderDia D.SVG (D.SVGOptions (D.mkWidth 250) Nothing "") dia
examples/using-qrcode.hs view
@@ -1,4 +1,5 @@-import Text.Blaze.Svg.Renderer.Utf8 (renderSvg) -- blaze-svg+{-# LANGUAGE OverloadedStrings #-}+import Lucid.Svg (renderBS) -- lucid-svg import qualified Codec.Binary.QRCode as QR -- qrcode import qualified Data.ByteString.Lazy.Char8 as L8 -- bytestring import qualified Diagrams.Backend.SVG as D -- diagrams-svg@@ -18,4 +19,4 @@ let dia = D.scale 6 $ QR.stroke $ QR.pathArray $ fmap not $ QR.toArray qrcode -- Render diagram- L8.putStrLn $ renderSvg $ D.renderDia D.SVG (D.SVGOptions D.Absolute Nothing) dia+ L8.putStrLn $ renderBS $ D.renderDia D.SVG (D.SVGOptions (D.mkWidth 250) Nothing "") dia
src/Diagrams/QRCode.hs view
@@ -4,7 +4,8 @@ import Control.Arrow ((***)) import Data.Array (assocs, Array, Ix) import Data.Colour.Names (black, white)-import Data.Monoid (mempty)+import Data.Monoid (Any, mempty)+import qualified Diagrams.Attributes as D import qualified Diagrams.Core as D import qualified Diagrams.Located as D import qualified Diagrams.Path as D@@ -14,7 +15,9 @@ -- | Stroke using default QR code colors (black on white) and -- with the \"quiet\" region.-stroke :: (D.Backend b D.R2, D.Renderable (D.Path D.R2) b) => D.Path D.R2 -> D.Diagram b D.R2+stroke :: (D.Backend b D.V2 Double, D.Renderable (D.Path D.V2 Double) b)+ => D.Path D.V2 Double+ -> D.QDiagram b D.V2 Double Any stroke = D.bg white . quiet . D.fc black . D.lw D.none . D.stroke where zoneX = D.strutX 4@@ -30,14 +33,14 @@ -- | Convert a QR code represented as a list of bounded values -- into a 'Path'. 'minBound' values are considered to be -- \"off\", while every other value is considered to be \"on\".-pathList :: (Bounded a, Eq a, Integral ix) => [((ix, ix), a)] -> D.Path D.R2+pathList :: (Bounded a, Eq a, Integral ix) => [((ix, ix), a)] -> D.Path D.V2 Double pathList = D.Path . fmap (uncurry (flip D.at) . (p2int *** toTrail)) where p2int = D.p2 . (fromIntegral *** fromIntegral) -- | Same as 'pathList', but from a matrix represented as a list -- of lists.-pathMatrix :: (Bounded a, Eq a) => [[a]] -> D.Path D.R2+pathMatrix :: (Bounded a, Eq a) => [[a]] -> D.Path D.V2 Double pathMatrix matrix = pathList $ do (r, row) <- count matrix@@ -47,10 +50,10 @@ -- | Same as 'pathList', but from an array.-pathArray :: (Bounded a, Eq a, Integral ix, Ix ix) => Array (ix, ix) a -> D.Path D.R2+pathArray :: (Bounded a, Eq a, Integral ix, Ix ix) => Array (ix, ix) a -> D.Path D.V2 Double pathArray = pathList . assocs -- | Convert a value into a 'Trail'.-toTrail :: (Bounded a, Eq a) => a -> D.Trail D.R2+toTrail :: (Bounded a, Eq a) => a -> D.Trail D.V2 Double toTrail x = if x == minBound then mempty else D.square 1