×

Welcome to TagMyCode

Please login or create account to add a snippet.
2
0
 
0
Language: Javascript
Posted by: petecocoon
Added: Mar 28, 2011 9:49 AM
Views: 197
  1. /* Defining some data type*/
  2. function rect(x, y, w, h){
  3.   return {'x' : x, 'y' : y, 'width' : w, 'height' : h};
  4. }
  5.  
  6. function point(x,y){
  7.   return {'x' : x, 'y' : y};
  8. }
  9.  
  10. /* return true if the point is inside the rect, false otherwise*/
  11. function pointInRect(point, rect)
  12. {
  13.   return (point.x >= rect.x &&
  14.           point.x <= (rect.x + rect.w) &&
  15.           point.y >= rect.y &&
  16.           (point.y <= rect.y + rect.h));
  17. }
  18.