3 ms·
I think a good way to start would be to have a look I the source code, fork it and experiment on it: https://github.com/plehoux/fontBomb/tree/master/src/coffee
by plehoux 14y ago
I think a good way to start would be to have a look I the source code, fork it and experiment on it: https://github.com/plehoux/fontBomb/tree/master/src/coffee https://github.com/plehoux/fontBomb/tree/master/src/coffee
If you want to google your way out of it start with something like "CSS 2d transform".
There's a lot of differents technologies going on in the background, but it still fairly simple to understand.
1. I parse the the html to wrap each character in a <particle> tag. + Some hacks, to keep withespace.
2. I iterate trough all <particle> element and add velocity depending of bomb position.
3. Velocity is calculated with basic trigonometry. I then move the particules with css 2d transform.
ps. I putted a lot of effort in optimisation, no Math.sqrt, no objects in the loop (velocityX vs velocity.x), etc. But at the end the bottleneck is really the browser rendering.
- dmak 14y agoI'm going to look through the code now. What I don't understand is how do you manipulate letters like that? I always though font was this static thing that cannot be manipulated. This is mind opening. I am really interested and want to learn more about this. What technology is allowing you to grab a letter and just randomly blow it away?
- emmelaich 14y agoI don't think you can, directly. You have to turn each letter into an element (a div or span typically) I'm reading the source, but can't see where he does this exactly. (I'm a javascript newbie) Edit: look in explosion.coffee, function explosifyText It uses string split and puts the chars in either a word or particle element.
- dmak 14y agoThanks!