Pack line to list give better gfx result, otherwise in can result in aliasing gaps '11010111' -> [2, -1, 1, -1, 3] This method will yield a sequence of pairs (width, height_factor). :param line: A string matching the writer spec (only contain 0 or 1 or G).
(self, line: str)
| 195 | setattr(self, key, val) |
| 196 | |
| 197 | def packed(self, line: str) -> Generator[tuple[int, float], str, None]: |
| 198 | """ |
| 199 | Pack line to list give better gfx result, otherwise in can |
| 200 | result in aliasing gaps |
| 201 | '11010111' -> [2, -1, 1, -1, 3] |
| 202 | |
| 203 | This method will yield a sequence of pairs (width, height_factor). |
| 204 | |
| 205 | :param line: A string matching the writer spec (only contain 0 or 1 or G). |
| 206 | """ |
| 207 | line += " " |
| 208 | c = 1 |
| 209 | for i in range(len(line) - 1): |
| 210 | if line[i] == line[i + 1]: |
| 211 | c += 1 |
| 212 | else: |
| 213 | if line[i] == "1": |
| 214 | yield (c, 1) |
| 215 | elif line[i] == "G": |
| 216 | yield (c, self.guard_height_factor) |
| 217 | else: |
| 218 | yield (-c, self.guard_height_factor) |
| 219 | c = 1 |
| 220 | |
| 221 | def render(self, code: list[str]): |
| 222 | """Renders the barcode to whatever the inheriting writer provides, |