def makeImpl(self, test, mask_pattern): self.modules_count = self.version * 4 + 17 self.modules = [None] * self.modules_count for row in range(self.modules_count): self.modules[row] = [None] * self.modules_count for col in range(self.modules_count): self.modules[row][col] = None # (col + row) % 3 self.setup_position_probe_pattern(0, 0) self.setup_position_probe_pattern(self.modules_count - 7, 0) self.setup_position_probe_pattern(0, self.modules_count - 7) self.sutup_position_adjust_pattern() self.setup_timing_pattern() self.setup_type_info(test, mask_pattern) if self.version >= 7: self.setup_type_number(test) if self.data_cache is None: self.data_cache = util.create_data( self.version, self.error_correction, self.data_list) self.map_data(self.data_cache, mask_pattern)
def makeImpl(self, test, mask_pattern): util.check_version(self.version) self.modules_count = self.version * 4 + 17 if self.version in precomputed_qr_blanks: self.modules = copy_2d_array(precomputed_qr_blanks[self.version]) else: self.modules = [None] * self.modules_count for row in range(self.modules_count): self.modules[row] = [None] * self.modules_count self.setup_position_probe_pattern(0, 0) self.setup_position_probe_pattern(self.modules_count - 7, 0) self.setup_position_probe_pattern(0, self.modules_count - 7) self.setup_position_adjust_pattern() self.setup_timing_pattern() precomputed_qr_blanks[self.version] = copy_2d_array(self.modules) self.setup_type_info(test, mask_pattern) if self.version >= 7: self.setup_type_number(test) if self.data_cache is None: self.data_cache = util.create_data(self.version, self.error_correction, self.data_list) self.map_data(self.data_cache, mask_pattern)
def makeImpl(self, test, mask_pattern, use_colors=True): _check_version(self.version) self.modules_count = self.version * 4 + 17 self.modules = [None] * self.modules_count for row in range(self.modules_count): self.modules[row] = [None] * self.modules_count for col in range(self.modules_count): self.modules[row][col] = None # (col + row) % 3 self.setup_position_probe_pattern(0, 0, use_colors=use_colors) self.setup_position_probe_pattern(self.modules_count - 7, 0, use_colors=use_colors) self.setup_position_probe_pattern(0, self.modules_count - 7, use_colors=use_colors) self.setup_position_adjust_pattern(use_colors=use_colors) self.setup_timing_pattern(use_colors=use_colors) self.setup_type_info(test, mask_pattern, use_colors=use_colors) if self.version >= 7: self.setup_type_number(test, use_colors=use_colors) if self.data_cache is None: self.data_cache = util.create_data( self.version, self.error_correction, self.data_list, self.colors, self.control_colors, copy_colors_to_ec=self.copy_colors_to_ec) self.map_data(self.data_cache, mask_pattern, use_colors=use_colors)
def best_fit(self, start=None): """ Find the minimum size required to fit in the data. """ size = start or 1 while True: try: self.data_cache = util.create_data(size, self.error_correction, self.data_list) except exceptions.DataOverflowError: size += 1 else: self.version = size return size
def addData(self, data): self.listData.append(util.QRData(data)) self.dataEncode = util.create_data(self.version, 1, self.listData)