Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Resizing behavior on with skia rendere #476

Open
TyTodd opened this issue Mar 17, 2025 · 0 comments
Open

Unexpected Resizing behavior on with skia rendere #476

TyTodd opened this issue Mar 17, 2025 · 0 comments

Comments

@TyTodd
Copy link

TyTodd commented Mar 17, 2025

Rendering the image normally without attempting to resize, with image(img, 10,20)
I get this:

Image

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()
Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant