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

Small question, do ALL canvas only support floats for XY(Z) positioning, widths, etc. #4480

Open
GhbSmwc opened this issue Dec 24, 2020 · 8 comments
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement
Milestone

Comments

@GhbSmwc
Copy link

GhbSmwc commented Dec 24, 2020

I check out the canvas documentations and it seems that only floating point are supported, despite Vector2i and Vector3i exists. For vector2i, the units are in pixels, not sure if godot allows values to be halfway between pixels.

@Calinou
Copy link
Member

Calinou commented Dec 24, 2020

Vector2i and Vector3i are only available in master (what will become Godot 4.0), not 3.2.x.

Also, yes, floating-point canvas coordinates are allowed.

@GhbSmwc
Copy link
Author

GhbSmwc commented Dec 24, 2020

@Calinou How does godot render between-pixels? Unless it simply rounds downwards. Good thing these precision loss will only occur far offscreen (no monitors would have 2^52 or 2^23 number of pixels wide and tall)

@Calinou
Copy link
Member

Calinou commented Dec 24, 2020

How does godot render between-pixels? Unless it simply rounds downwards

By default, it doesn't attempt to round pixel coordinates. This means things can move smoothly on screen, but it'll also make things blurrier. You can enable pixel snap in the Project Settings to make sure all pixel transforms are snapped before rendering.

@GhbSmwc
Copy link
Author

GhbSmwc commented Dec 24, 2020

@Calinou So Godot actually supports displaying “sub-pixels”. Cool.

@GhbSmwc
Copy link
Author

GhbSmwc commented Dec 25, 2020

Also, according to this, will many other things related to textures being drawn, such as controls's properties (margin, size, position, global position etc.)?

@Calinou
Copy link
Member

Calinou commented Dec 25, 2020

Also, according to this, will many other things related to textures being drawn, such as controls's properties (margin, size, position, global position etc.)?

No, as Controls are snapped to pixels by default, even if the properties themselves allow floating-point values. You can disable this by unchecking Snap Controls To Pixels in the Project Settings. If you disable Snap Controls To Pixels, text and other UI elements will be able to move to sub-pixel positions but will become less crisp.

@GhbSmwc
Copy link
Author

GhbSmwc commented Dec 25, 2020

@Calinou Ack, that last sentence was a fragment, I was meant to say:

“Also, according to this, will many other things related to textures being drawn, such as controls's properties (margin, size, position, global position etc.) support integer?”

One last question: When pixel snapping is turned on, does internally that they're handled as ints (if you set it to a fractional value, it rounds into a whole number upon type conversion)? This is in case if you are reading the position of a rectangle after setting it to X=0.5 and it returns 0.

@Calinou
Copy link
Member

Calinou commented Dec 25, 2020

One last question: When pixel snapping is turned on, does internally that they're handled as ints (if you set it to a fractional value, it rounds into a whole number upon type conversion)? This is in case if you are reading the position of a rectangle after setting it to X=0.5 and it returns 0.

I don't remember, but the way transforms are snapped was revised for 3.2.4 in godotengine/godot#43554. 3.2.3 still uses the old transform snapping code.

@skyace65 skyace65 added the area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository label Dec 28, 2022
@tetrapod00 tetrapod00 added this to the 3.x milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement
Projects
None yet
Development

No branches or pull requests

4 participants