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

Differentiate Image's get_data() and Texture's get_data() #517

Closed
rainlizard opened this issue Feb 24, 2020 · 5 comments
Closed

Differentiate Image's get_data() and Texture's get_data() #517

rainlizard opened this issue Feb 24, 2020 · 5 comments
Milestone

Comments

@rainlizard
Copy link

rainlizard commented Feb 24, 2020

Describe the project you are working on:
Projects that deal with the Image and Texture classes.

Describe the problem or limitation you are having in your project:
Poor clarity in GDScript. I was helping someone with their code earlier today and I got them mixed up again for the 3rd time.
Your code can even look like this: variable.get_data().get_data() which is just crazy. You will often be handling both classes in the same script and both classes are calling what appears to be the same function. Knowing about the difference between a "texture" and "image" in Godot is already another point of confusion in itself.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Rename one of them and clarity will be improved. Now may be the best time to ask, considering other things are being renamed: godotengine/godot#30736

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Any kind of rename, I don't mind how they are differentiated.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
It will be used often.

Is there a reason why this should be core and not an add-on in the asset library?:
This is about GDScript.

@clayjohn
Copy link
Member

This sounds like a good idea. Do you have a better name in mind?

@rainlizard
Copy link
Author

I figured I'd leave it to the experts, the most important thing was seeing if others felt the same way. But as a starting point:

Texture class's function could become get_image(), since the Image class is the one that has much more to do with "data".

In the docs the create_from_data() function says it "Fills the image with the given raw data." so Image class's function could potentially become get_raw_data(), but this may be unnecessary if the other rename is implemented.

Interestingly OpenSimplexNoise has a function named get_image() which returns an Image, so that would line up well with renaming Texture class's function to be get_image() as well.
One of big the issues with both these get_data() functions having the same name is that they each return different data (PoolByteArray and Image) which causes confusion and errors.

@Sslaxx
Copy link

Sslaxx commented Feb 24, 2020

Functions like these (and I'm sure these are not the only two instances) should be renamed ala get_image_data/get_texture_data, i.e. make it more explicit (along the pattern of get_nameofnodetypehere_data).

@Calinou Calinou changed the title Differentiate Image's get_data() and Texture's get_data() Differentiate Image's get_data() and Texture's get_data() Jan 31, 2021
@lyuma
Copy link

lyuma commented Dec 8, 2021

Since godotengine/godot#47435 was merged, is this issue resolved in master?

Texture.get_data() is now Texture.get_image()

@rainlizard
Copy link
Author

Oh, it's in. Thanks @madmiraal
I didn't see that pull request and he may not have seen this proposal either lol.

@Calinou Calinou added this to the 4.0 milestone Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants