forked from lincolnloop/python-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
425 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# For backwards compatibility, importing the PIL drawers here. | ||
from .pil import CircleModuleDrawer # noqa: F401 | ||
from .pil import GappedSquareModuleDrawer # noqa: F401 | ||
from .pil import HorizontalBarsDrawer # noqa: F401 | ||
from .pil import RoundedModuleDrawer # noqa: F401 | ||
from .pil import SquareModuleDrawer # noqa: F401 | ||
from .pil import VerticalBarsDrawer # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from __future__ import absolute_import | ||
|
||
import abc | ||
from typing import TYPE_CHECKING, Union | ||
|
||
if TYPE_CHECKING: | ||
from qrcode.image.base import BaseImage | ||
from qrcode.main import ActiveWithNeighbors | ||
|
||
|
||
class QRModuleDrawer(abc.ABC): | ||
""" | ||
QRModuleDrawer exists to draw the modules of the QR Code onto images. | ||
For this, technically all that is necessary is a ``drawrect(self, box, | ||
is_active)`` function which takes in the box in which it is to draw, | ||
whether or not the box is "active" (a module exists there). If | ||
``needs_neighbors`` is set to True, then the method should also accept a | ||
``neighbors`` kwarg (the neighboring pixels). | ||
It is frequently necessary to also implement an "initialize" function to | ||
set up values that only the containing Image class knows about. | ||
For examples of what these look like, see doc/module_drawers.png | ||
""" | ||
|
||
needs_neighbors = False | ||
|
||
def initialize(self, img: "BaseImage") -> None: | ||
self.img = img | ||
|
||
@abc.abstractmethod | ||
def drawrect(self, box, is_active: "Union[bool, ActiveWithNeighbors]") -> None: | ||
... |
Oops, something went wrong.