def load_image(self, v14_image): if v14_image: if v14_image.jpegBytes: image = kurt.Image(v14_image.jpegBytes.value, "JPEG") if hasattr(v14_image, 'size'): image._size = v14_image.size else: form = v14_image.compositeForm or v14_image.form pil_image = form.to_array() image = kurt.Image(pil_image) return kurt.Costume(v14_image.name, image, v14_image.rotationCenter)
def read_image(self, file_id): if file_id not in self.loaded_images: if file_id not in self.image_filenames: return None filename = self.image_filenames[file_id] (_, extension) = os.path.splitext(filename) contents = self.zip_file.open(filename).read() _format = kurt.Image.image_format(extension) self.loaded_images[file_id] = kurt.Image(contents, _format) return self.loaded_images[file_id]
for name in ("i", "j", "word x", "message"): sprite.variables[name] = kurt.Variable(0) sprite.lists["widths"] = kurt.List() error = False for char in CHARACTERS: pil_image = text_to_image(font, char, TEXT_COLOR) (width, height) = pil_image.size if char == " " and width == 0 or height == 0: width = max(1, width) height = max(1, width) pil_image = Image.new("RGB", (width, height), (255, 255, 255)) try: costume = kurt.Costume(char, kurt.Image(pil_image), (0, 0)) except SystemError: error = True break sprite.costumes.append(costume) if char == 'A': sprite.costume = costume sprite.lists["widths"].items.append(costume.width) line_height = max(line_height, costume.height) if error: continue sprite.parse(""" when gf clicked