MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / drawParticles

Function drawParticles

assets/confetti_js/confetti.js:165–186  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

163 }
164
165 function drawParticles(context) {
166 var particle;
167 var x, y, x2, y2;
168 for (var i = 0; i < particles.length; i++) {
169 particle = particles[i];
170 context.beginPath();
171 context.lineWidth = particle.diameter;
172 x2 = particle.x + particle.tilt;
173 x = x2 + particle.diameter / 2;
174 y2 = particle.y + particle.tilt + particle.diameter / 2;
175 if (confetti.gradient) {
176 var gradient = context.createLinearGradient(x, particle.y, x2, y2);
177 gradient.addColorStop("0", particle.color);
178 gradient.addColorStop("1.0", particle.color2);
179 context.strokeStyle = gradient;
180 } else
181 context.strokeStyle = particle.color;
182 context.moveTo(x, particle.y);
183 context.lineTo(x2, y2);
184 context.stroke();
185 }
186 }
187
188 function updateParticles() {
189 var width = window.innerWidth;

Callers 1

runAnimationFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected