March 3, 2017 01:34 pm GMT
Original Link: http://mediatemple.net/blog/tips/randomizing-svg-shapes/
Randomizing SVG Shapes
SVG shapes are all built from numbers. Obvious, perhaps, but also, I'm not sure we take as much advantage of that as we could with inline <svg>
. For example, it's pretty easy to generate a new pseudo-random number in JavaScript:
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
Now imagine a bunch of variables set to random numbers, and using ES6 template literals to stitch them together:
let newPoints = `${x1},${y1} {x2},${y2}
…
Randomizing SVG Shapes is a post from CSS-Tricks
Original Link: http://mediatemple.net/blog/tips/randomizing-svg-shapes/
Share this article:
Tweet
View Full Article