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

ebitenutil: DebugPrint ignoring image origin #2977

Open
11 tasks
tinne26 opened this issue May 1, 2024 · 5 comments
Open
11 tasks

ebitenutil: DebugPrint ignoring image origin #2977

tinne26 opened this issue May 1, 2024 · 5 comments
Labels
Milestone

Comments

@tinne26
Copy link

tinne26 commented May 1, 2024

Ebitengine Version

v2.7.2

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

go1.22.2

What steps will reproduce the problem?

Using ebitenutil.DebugPrint() on an image with non-zero origin.

What is the expected result?

Text drawing on the top left.

What happens instead?

Text being cut or not visible.

Anything else you feel useful to add?

E.g., see https://github.com/hajimehoshi/ebiten/blob/v2.7.2/ebitenutil/debugprint.go#L48C3-L48C32 trivially replace with:

bounds := image.Bounds()
DebugPrintAt(image, str, bounds.Min.X, bounds.Min.Y)
@tinne26 tinne26 added the bug label May 1, 2024
@hajimehoshi hajimehoshi added this to the v2.8.0 milestone May 1, 2024
@tinne26
Copy link
Author

tinne26 commented May 1, 2024

I mean, I'm unsure of the exact desired behaviors, in some cases DebugPrintAt() might also need some changes, in which case the fix would be more involved?

@hajimehoshi
Copy link
Owner

I feel like this is an expected behavior.

@Zyko0
Copy link
Contributor

Zyko0 commented May 2, 2024

I feel like this is an expected behavior.

Yes, I think it's for the same reason that if you do DrawImage to a sub-image, you also have to translate the origin of the destination sub-image explicitely.

edit: maybe this is not really desirable (?) but at least it seems consistent with the other API behaviours regarding sub-images

@tinne26
Copy link
Author

tinne26 commented May 2, 2024

I mean, the documentation says:

DebugPrint draws the string str on the image on left top corner.

There are two possible interpretations of this:

  1. "[...] draws the string on image's top-left corner", in which case, top-left corner is the image's origin, and the function description doesn't match its current behavior, as an image origin is image.Bounds().Min.
  2. "[...] draws the string on image, at coordinates (0, 0)", in which case, the current documentation is very ambiguous and easy to misinterpret. Notice that (0, 0) is not even the top-left corner of the screen, but technically, the top-left corner of the parent of image. So even trying to rewrite as "[...] draws the string on image, on the top-left corner of the screen" wouldn't be technically correct. An alternative description would be "with no translation".

I'm fine with current behavior being the desired one, but I don't think the most reasonable interpretation of the function description matches the current behavior.

Regarding Zyko's comment, DrawImage() doesn't have this problem, and in fact, you depend on GeoM, which has this explicit documentation:

// The default (zero) value is identity, which draws the image at (0, 0).

So, I think there is no parallel with DrawImage() here, this is purely on DebugPrint()'s description / behavior mismatch.

@hajimehoshi
Copy link
Owner

Ok so I'd like to update the documentation side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants