QRCodeWidget ignores the barFillColor parameter

Lele Gaifax <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Organization Nautilus Entertainments
Message-ID <[email protected]>
Hi,

needing to draw a QRCode painted in white on a dark background, I see that the
method QRCodeWidget.add() ignores the color passed as "barFillColor". I had to
change it like below (see comment "# LG: "):

    def draw(self):
        self.qr.make()

        g = Group()

        color = self.barFillColor
        border = self.barBorder
        width = self.barWidth
        height = self.barHeight
        x = self.x
        y = self.y

        g.add(SRect(x, y, width, height, fillColor=None))

        moduleCount = self.qr.getModuleCount()
        minwh = float(min(width, height))
        boxsize = minwh / (moduleCount + border * 2.0)
        offsetX = x + (width - minwh) / 2.0
        offsetY = y + (minwh - height) / 2.0

        for r, row in enumerate(self.qr.modules):
            row = map(bool, row)
            c = 0
            for t, tt in itertools.groupby(row):
                isDark = t
                count = len(list(tt))
                if isDark:
                    x = (c + border) * boxsize
                    y = (r + border + 1) * boxsize
                    # LG: actually use the specified barFillColor
                    s = SRect(offsetX + x, offsetY + height - y, count * boxsize, boxsize,
                              fillColor=color)
                    g.add(s)
                c += count

        return g

Does this sound right?

thanks&bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected]  |                 -- Fortunato Depero, 1929.

_______________________________________________
reportlab-users mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/reportlab-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.