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

Blits are zoomed as if their center is the top-left corner and not center of image #591

Open
bferguson3 opened this issue Dec 29, 2024 · 1 comment

Comments

@bferguson3
Copy link

This is difficult to explain so bear with me -

If you blit a 10x10 square onto 0,0, it will cover the span of (0 to 10, 0 to 10).

If you blit that square with a zoom of 2, if will cover the span of (-10 to 10, 0 to 20).

There is no way of blitting an image to a specific xy dimensions unless you know the exact dimensions, in units of the size/scale of image you are blitting, and without performing extra manipulative x math to get it in the right position.

The ideal behavior here would be the x,y position you define in the function parameter is always the top-left corner - OR, an additional blt() definition where you can specify the exact dimensions, which afaik is how it is rendered behind the scenes anyway.

@squiddy
Copy link
Contributor

squiddy commented Dec 29, 2024

I agree, I'm currently having a helper function to help me blt always in the top-left corner.

Small example just to visualize the behaviour.

pyxel-20241229-170115

# /// script
# dependencies = [
#   "pyxel",
# ]
# ///

import pyxel

pyxel.init(100, 100)

pyxel.images[0].set(0, 0, ["3"*10]*10)
pyxel.blt(10, 10, 0, 0, 0, 10, 10, 0, scale=1)
pyxel.blt(10, 50, 0, 0, 0, 10, 10, 0, scale=2)
pyxel.blt(50, 50, 0, 0, 0, 10, 10, 0, scale=3)

# grid
for y in range(10, pyxel.height, 10):
    for x in range(10, pyxel.width, 10):
        pyxel.pset(x, y, 13)

# blt positions
pyxel.pset(10, 10, 8)
pyxel.pset(10, 50, 8)
pyxel.pset(50, 50, 8)

pyxel.show()

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

2 participants