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

Gradient config #28

Closed
tipsy opened this issue Apr 3, 2023 · 5 comments
Closed

Gradient config #28

tipsy opened this issue Apr 3, 2023 · 5 comments

Comments

@tipsy
Copy link
Owner

tipsy commented Apr 3, 2023

@abalazsik, I'm looking at the gradient config. We also don't support more than 2 color stops, but it would be simple enough to add any number, this could potentially replace "gradientLength".

@tipsy
Copy link
Owner Author

tipsy commented Apr 4, 2023

I made a change to how the angle works now, so that you specify degrees (0-360). You can no longer specify length.

@tipsy
Copy link
Owner Author

tipsy commented Apr 4, 2023

This still feels a bit limited. We could create

gradientFunc(context), which would let a user set a gradient for the context (and save us from complicated math in the library).

@tipsy
Copy link
Owner Author

tipsy commented Apr 4, 2023

bubbly({
  bubbles: 30,
  compose: 'lighter',
  shadowBlur: 1,
  shadowColor: '#fff',
  gradientFunc: (ctx) => {
    const gradient = ctx.createLinearGradient(0, 0, ctx.canvas.width, ctx.canvas.height);
    gradient.addColorStop(0, "#2AE");
    gradient.addColorStop(1, "#17B");
    return gradient;
  },
  radiusFunc: () => 4 + Math.random() * window.innerWidth / 25,
  fillFunc: () => `hsla(0, 0%, 100%, ${Math.random() * 0.1})`,
  angleFunc: () => Math.random() * Math.PI * 2,
  velocityFunc: () => 0.1 + Math.random() * 0.5,
  animate: true,
});

@tipsy
Copy link
Owner Author

tipsy commented Apr 4, 2023

Screen Shot 2023-04-04 at 05 41 17

@tipsy
Copy link
Owner Author

tipsy commented Apr 4, 2023

Actually, we can set the "fillStyle" rather than "a gradient". This will let us do this:

Screen.Recording.2023-04-04.at.06.22.14.mov

@tipsy tipsy closed this as completed Apr 5, 2023
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

1 participant