Hello everyone,
I'm working to animate an explosion on SVG but got stuck with it. I would like each element of SVG going in random direction from center.
Does anyone know a solution ?
See the Pen wzOxwO by anon (@anon) on CodePen
Using a little vector math, this is actually pretty easy to do. All you need to do is scale a vector. It's too bad JavaScript can't do operator overloading like a lot of other languages, because this could be a one-liner.
var newPoint = (point - center) * scalar;
Vectors are like points, but they have a definite direction and length, so the ratio between the x and y values is constant. This means you don't have to figure out the angle for a position. If you know the length o