Rectangle class
Dependents: FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot
Fork of Rectangle by
Rectangle.cpp
- Committer:
- dhamilton31
- Date:
- 2013-11-25
- Revision:
- 2:087e0b0b526c
- Parent:
- 1:d9c0709ba2ce
File content as of revision 2:087e0b0b526c:
#include "mbed.h" #include "Rectangle.h" Rectangle :: Rectangle(int x,int y, int xx, int yy) { x1 = x; x2 = xx; y1 = y; y2 = yy; } bool Rectangle :: is_touch(int x_touch , int y_touch) { if(x_touch >= x1 && x_touch <= x2) { if(y_touch >= y1 && y_touch <= y2) { return true; } } return false; } int Rectangle :: getX1() { return x1; } int Rectangle :: getX2() { return x2; } int Rectangle :: getY1() { return y1; } int Rectangle :: getY2() { return y2; } int Rectangle :: getCenterX() { return x1 + (x2-x1)/2; } int Rectangle :: getCenterY() { return y1 + (y2-y1)/2; }