QR Code image generator with customizable image formats, error correction levels, and styling options
Create a custom module drawer for QR codes that draws the regular QR modules as circles, but renders the position detection patterns (corner "eyes") with standard square shapes for better scannability.
Your custom drawer should:
Create a file custom_drawer.py that implements your custom module drawer class. The drawer should extend the appropriate base class and implement the necessary methods to achieve the mixed styling (circles for data, squares for eyes).
Create a file test_custom_drawer.py that verifies your implementation works correctly.
@generates
class CustomMixedDrawer:
"""
A custom module drawer that renders data modules as circles
and eye patterns as squares.
"""
def __init__(self, size_ratio=0.8):
"""
Initialize the custom drawer.
Parameters:
- size_ratio (float): Size ratio for the circle modules (0.0-1.0)
"""
passWhen used with the qrcode package, your drawer should produce QR codes where:
import qrcode
from qrcode.image.styledpil import StyledPilImage
from custom_drawer import CustomMixedDrawer
qr = qrcode.QRCode(
error_correction=qrcode.constants.ERROR_CORRECT_H,
image_factory=StyledPilImage
)
qr.add_data('Test QR Code')
qr.make()
img = qr.make_image(module_drawer=CustomMixedDrawer())
img.save('mixed_style_qr.png')Provides QR code generation with customizable styling.
@satisfied-by
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10