Particle Hydrodynamic Simulator

by Kyle Bezio

HTML

<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>

JavaScript

//canvas values
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

/**
Define particle Objects here
**/
function particle(x, y, sizedown, sizeup, sizeright, sizeleft, color){
	//assign the values
  this.x = x;
  this.y = y;
  this.sizedown = sizedown;
  this.sizeup = sizeup;
  this.sizeright = sizeright;
  this.sizeleft = sizeleft;
  this.color = color;
}
//draw the game piece
particle.prototype.draw = function(){
	//assign a color
  context.fillStyle = this.color;
  //draw a rectangle
  context.fillRect(this.x, this.y, this.size, this.size);
}