SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const canvas = document.querySelectorAll('canvas')[0]
  2. const ctx = canvas.getContext('2d')
  3. const height = canvas.getAttribute('height')
  4. const width = canvas.getAttribute('width')
  5.  
  6. const data = {
  7.     particles: [],
  8.   blackhole: {}
  9. }
  10.  
  11. function createCrust() {
  12.     for (let i=0; i<width; i++) {
  13.     let particle = {
  14.             weight: Math.floor(Math.random() * 5) + 1,
  15.       posY: (''+i)[0],
  16.       posX: (''+i)[1] + (''+i)[2]
  17.     }
  18.     data.particles.push(particle)
  19.   }
  20. }
  21.  
  22. function drawCrust(particles) {
  23.     for (let i=0; i<particles.length; i++) {
  24.     ctx.fillRect(
  25.         particles[i].posX,
  26.       particles[i].posY,
  27.       1,
  28.       1
  29.     )
  30.   }
  31. }
  32.  
  33. createCrust()
  34. drawCrust(data.particles)
  35.  
  36.  
  37. console.log(data.particles)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top