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

Fancy Draw #6

Open
wants to merge 4 commits into
base: 04-other-effects
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions source/lib/particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Particle {
this.drag = 0.98;
this.grav = 0.0125;

this.radius = 10;
this.radius = 16;
this.scale = 1.025;

this.alpha = 1;
Expand All @@ -35,12 +35,24 @@ export default class Particle {
render(ctx) {
const { px, py, radius, alpha } = this;

ctx.fillStyle = `rgba(255,255,255,${alpha})`;
ctx.globalAlpha = Math.max(0, alpha);

ctx.fillStyle = 'rgba(13,1,248,0.41)';
ctx.beginPath();
ctx.arc(px, py, radius, 0, ππ);
ctx.closePath();
ctx.fill();

ctx.fillStyle = 'rgba(134,129,254,0.73)';
ctx.beginPath();
ctx.arc(px, py, radius / 2, 0, ππ);
ctx.closePath();
ctx.fill();

ctx.fillStyle = 'rgba(255,255,255,1)';
ctx.beginPath();
ctx.arc(px, py, radius / 4, 0, ππ);
ctx.closePath();
ctx.fill();
}
}
2 changes: 1 addition & 1 deletion source/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ init((ctx, { ts, dts }, { w, h, hw, hh }) => {
});

// if we go above a limit, start removing particles
while (particles.length > 100) {
while (particles.length > 500) {
particles.shift();
}

Expand Down