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

Add an option to keep the alpha/a in a RGBA object return #211

Open
Nukiloco opened this issue Aug 8, 2021 · 2 comments
Open

Add an option to keep the alpha/a in a RGBA object return #211

Nukiloco opened this issue Aug 8, 2021 · 2 comments
Labels
BREAKING This is a breaking change bug pr welcome

Comments

@Nukiloco
Copy link

Nukiloco commented Aug 8, 2021

When for example the alpha is set to 1 in an RGBA object return, the alpha/a variable disappears. I know this is a part of the design of the library though this means that there has to be extra code checking to make sure the variable isn't missing before using it. Can there be an option where the RGBA object keeps it's alpha/a variable? Thanks!

@Qix-
Copy link
Owner

Qix- commented Aug 24, 2021

Yes that's strange, I think I remember the reasoning for it back then but it doesn't make much sense these days.

It should be changed, but I'm going to consider it a breaking change given how many people (mis)use this library.

@headwindz
Copy link
Contributor

I think a way to get this solved with backward compatibility is to add a third paramater to Color constructor which indicates whether we want to always keeps the alpha/a variable . E.g.

function Color(object, model, alwaysKeepAlpha = false) {
  this.alwaysKeepAlpha = alwaysKeepAlpha;
}

Then in the corresponding code, do:

if (this.alwaysKeepAlpha || (!this.alwaysKeepAlpha && this.valpha !== 1)) {
   result.alpha = this.valpha;
}  

@Qix- Qix- added the BREAKING This is a breaking change label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING This is a breaking change bug pr welcome
Projects
None yet
Development

No branches or pull requests

3 participants