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

Rename with_alpha_factor, add set_alpha? #51

Open
waywardmonkeys opened this issue Sep 13, 2024 · 3 comments
Open

Rename with_alpha_factor, add set_alpha? #51

waywardmonkeys opened this issue Sep 13, 2024 · 3 comments

Comments

@waywardmonkeys
Copy link
Contributor

From @simbleau on linebender/interpoli#2 (comment)

It would be nice to see a .set_alpha(alpha) added and rename .with_alpha_factor(alpha) to .multiply(alpha) or something

This was added as a breaking change since the last release and the suggestion now is to perhaps modify that in a breaking way, so I'd like this to be resolved before we do the impending release.

Related:

cc: @simbleau @dfrg

@DJMcNab
Copy link
Member

DJMcNab commented Sep 13, 2024

How do you propose we implement set_alpha for gradients @simbleau?

There are several different methods I can see, each with their own bad tradeoffs:

  1. Make each element have the alpha, ignoring any prior gradient in the alpha component
  2. Normalise the alphas so that they have a maximum of alpha; this means that the behaviour isn't really doing set_alpha
  3. Subtract from all of the alphas so the the largest is alpha
  4. Fix the smallest and normalise so that the maximum is alpha

@simbleau
Copy link
Member

simbleau commented Sep 14, 2024

I would guess (1): overwrite the alpha of each stop with the given value.

DJMcNab added a commit to DJMcNab/peniko that referenced this issue Sep 16, 2024
@DJMcNab
Copy link
Member

DJMcNab commented Sep 16, 2024

I've done the breaking part of this in #52 to unblock this issue. A new set_alpha can be added separately.

If set_alpha is needed, I'd prefer it to be external due to the muddy semantics when gradients have different colour modes. Either way, if #52 lands, that should unblock a release.

github-merge-queue bot pushed a commit that referenced this issue Sep 17, 2024
@waywardmonkeys waywardmonkeys changed the title Change with_alpha_factor Rename with_alpha_factor, add set_alpha? Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants