@@ -94,6 +94,39 @@ def drawrect(self, box, is_active: bool):
9494 self .img ._img .paste (self .circle , (box [0 ][0 ], box [0 ][1 ]))
9595
9696
97+ class GappedCircleModuleDrawer (StyledPilQRModuleDrawer ):
98+ """
99+ Draws the modules as circles that are not contiguous.
100+
101+ The size_ratio determines how wide the circles are relative to the width of
102+ the space they are printed in
103+ """
104+
105+ circle = None
106+
107+ def __init__ (self , size_ratio = 0.9 ):
108+ self .size_ratio = size_ratio
109+
110+ def initialize (self , * args , ** kwargs ):
111+ super ().initialize (* args , ** kwargs )
112+ box_size = self .img .box_size
113+ fake_size = box_size * ANTIALIASING_FACTOR
114+ self .circle = Image .new (
115+ self .img .mode ,
116+ (fake_size , fake_size ),
117+ self .img .color_mask .back_color ,
118+ )
119+ ImageDraw .Draw (self .circle ).ellipse (
120+ (0 , 0 , fake_size , fake_size ), fill = self .img .paint_color
121+ )
122+ smaller_size = int (self .size_ratio * box_size )
123+ self .circle = self .circle .resize ((smaller_size , smaller_size ), Image .Resampling .LANCZOS )
124+
125+ def drawrect (self , box , is_active : bool ):
126+ if is_active :
127+ self .img ._img .paste (self .circle , (box [0 ][0 ], box [0 ][1 ]))
128+
129+
97130class RoundedModuleDrawer (StyledPilQRModuleDrawer ):
98131 """
99132 Draws the modules with all 90 degree corners replaced with rounded edges.
0 commit comments