Skip to content

Instantly share code, notes, and snippets.

@lewdev
Created October 8, 2023 10:48
Show Gist options
  • Select an option

  • Save lewdev/66c5dda4021d8ecfc84ee88776ad2b9b to your computer and use it in GitHub Desktop.

Select an option

Save lewdev/66c5dda4021d8ecfc84ee88776ad2b9b to your computer and use it in GitHub Desktop.
πŸ”₯ Making a fire-particle effect using emojis
<style>html,body{background:#222;display:flex;justify-content:center;align-items:center;height:100%;margin:0}#c{background:white;max-height:100%;max-width:100%}</style>
<canvas id=c width=1080 height=1080></canvas>
<script>
x=c.getContext`2d`,lfr=1,S=Math.sin,C=Math.cos,T=Math.tan,R=(r,g,b,a=1)=>`rgba(${r|0},${g|0},${b|0},${a})`,t=f=nfm=0;z=t=>{
c.width|=0
t||(e=500,R=Math.random,a=new Array(e).fill({X:e,Y:e,}).map((b,i)=>({...b,Z:R()*(-Math.PI),T:0})))
x.font="1in'"
for(d of a)(t>d.T?(d.T=t+R(),d.X=e,d.Y=e):0,x.fillText('πŸ”₯',d.X+=C(d.Z),d.Y+=S(d.Z)*3))
};loop=fTime=>{requestAnimationFrame(loop);if(lfr&&fTime<nfm-2)return;nfm=Math.max(nfm+1e3/60,fTime);t=f/60;if(t*60|0!=f++)t+=1e-6;z(t)};loop()
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment