-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Description
Rendering the image normally without attempting to resize, with image(img, 10,20)
I get this:
However when trying to dynamically resize the width to half its size I get the image below
from p5 import *
from components.shuffler import Shuffler
from components.debugger import Debugger
from game_logic.constants import ITEMS
# Intellisense can't find these on its own for some reason
global mouse_is_pressed, mouse_x, mouse_y
global shuffler, debugger
global width, height
SHUFFLED_ITEMS = list(ITEMS.keys())
img = None
img_width = None
img_height = None
def start():
"""
Start the UI. This function takes over the main thread (never returns)!
"""
run(renderer="skia", sketch_draw=draw, sketch_setup=setup)
def setup():
size(1024, 600) #touchscreen size
background(200)
global shuffler, debugger, img, img_width, img_height
shuffler = Shuffler()
debugger = Debugger()
img = loadImage("kart_ui/images/no-item.png")
print("original size", img.width(), img.height())
img_width = int(img.width()/2)
img_height = int(img.height()/2)
# no_tint()
def draw():
background(255)
fill(255)
# print(type(img))
# print(img_width, img_height)
image(img, 10,20, img_width, img_height)
def mouse_pressed():
if mouse_x < width/2:
shuffler.shuffle(SHUFFLED_ITEMS[int(random_uniform(0, len(SHUFFLED_ITEMS)))])
else:
shuffler.use_item()
if __name__ == "__main__":
start()
Metadata
Metadata
Assignees
Labels
No labels