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

Textures should have a way to erase a portion of the texture via a size / width / height #6853

Closed
SelfDevTV opened this issue Jul 1, 2024 · 8 comments · May be fixed by jonesrussell/nishman#6
Assignees

Comments

@SelfDevTV
Copy link

SelfDevTV commented Jul 1, 2024

The problem

I have a dynamic texture I draw 1000s of numbers on it (via Phaser.Gameobjects.Text or BitmapText) and via tex.draw(). Sometimes I want to remove the text from a specific location on the texture. The only way I found this was via .erase.
Problem is it only takes in a Gameobject but not the size itself. When i give it my text gameobject it will remove it but in a very weird way. Here is a screenshot:

image

A fellow discord mate helped me out with a workaround:

const rect = this.add.rectangle(0, 0, 10, 10, 0);
dynTexture.erase(rect, 0, 0);

But still I thought why not implement another way of this function, that will also take in a size or width + height parameter. I would also like to try to implement it.

API for example for a DynamicTexture might look like this: dynTexture.erase(width: number, height: number = width, x: ....)

[Optional] Do you want to help provide this feature?
Yes. API for example for a DynamicTexture might look like this: dynTexture.erase(width: number, height: number = width, x: ....)

@rexrainbow
Copy link
Contributor

How about clearRect method name, similar as clearRect in canvas api

@SelfDevTV
Copy link
Author

SelfDevTV commented Jul 1, 2024

Yes that could work too. Infact i was searching for this method at first, but then found it's called erase.
@rexrainbow do you know how that normally works? Should I just create a fork go ahead and send a PR or do we talk about it first / have to get assigned first. etc?
Sorry would be my first contribution kinda

@photonstorm
Copy link
Collaborator

clear already exists - it would be easier to just allow you to pass 4 optional parameters to it, rather than increase the API size.

erase is not the same thing, that uses a special blend mode and the pixels from the textures to remove it, and then you have to factor in alpha blending on non-opaque pixels too. It's meant more as a way to punch a 'shape' into a dynamic texture, than to clear an area.

@SelfDevTV
Copy link
Author

SelfDevTV commented Jul 2, 2024

clear already exists - it would be easier to just allow you to pass 4 optional parameters to it, rather than increase the API size.

Yes that would be the best way I think. It should take 4 optional parameters ala x: number, y: number, width: number, height: number = width or something like that.

erase is not the same thing, that uses a special blend mode and the pixels from the textures to remove it, and then you have to factor in alpha blending on non-opaque pixels too. It's meant more as a way to punch a 'shape' into a dynamic texture, than to clear an area.

Ok understood now :) thx for clarifying

@cy920820
Copy link

cy920820 commented Jul 3, 2024

The problem

I have a dynamic texture I draw 1000s of numbers on it (via Phaser.Gameobjects.Text or BitmapText) and via tex.draw(). Sometimes I want to remove the text from a specific location on the texture. The only way I found this was via .erase. Problem is it only takes in a Gameobject but not the size itself. When i give it my text gameobject it will remove it but in a very weird way. Here is a screenshot:

image

A fellow discord mate helped me out with a workaround:

const rect = this.add.rectangle(0, 0, 10, 10, 0);
dynTexture.erase(rect, 0, 0);

But still I thought why not implement another way of this function, that will also take in a size or width + height parameter. I would also like to try to implement it.

API for example for a DynamicTexture might look like this: dynTexture.erase(width: number, height: number = width, x: ....)

[Optional] Do you want to help provide this feature? Yes. API for example for a DynamicTexture might look like this: dynTexture.erase(width: number, height: number = width, x: ....)

Are you running full screen on a mobile device? The font is so blurry

@SelfDevTV
Copy link
Author

Just zoomed in by a lot with the main cam. Maybe that's why

@zekeatchan
Copy link
Collaborator

Hi @SelfDevTV, thanks for submitting this feature request.

We have implemented the feature that will allow you to clear a specified area of a dynamic texture like so:
dynamicTexture.clear(x, y, width, height)

This update has been pushed to the master branch and will be part of the next release. Do test it out and feel free to reach out if you need further assistance.

@SelfDevTV
Copy link
Author

Hi @SelfDevTV, thanks for submitting this feature request.

We have implemented the feature that will allow you to clear a specified area of a dynamic texture like so: dynamicTexture.clear(x, y, width, height)

This update has been pushed to the master branch and will be part of the next release. Do test it out and feel free to reach out if you need further assistance.

OMG you guys are awesome. Keep it up :) Thank you very much!

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

Successfully merging a pull request may close this issue.

5 participants