Rectangle class

Dependents:   FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot

Fork of Rectangle by Sensovery Company

Committer:
dhamilton31
Date:
Mon Nov 25 19:54:02 2013 +0000
Revision:
2:087e0b0b526c
Parent:
1:d9c0709ba2ce
No edit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
projetremote 0:19fca77774b6 1 #include "mbed.h"
projetremote 0:19fca77774b6 2 #include "Rectangle.h"
projetremote 0:19fca77774b6 3
projetremote 0:19fca77774b6 4
dhamilton31 2:087e0b0b526c 5 Rectangle :: Rectangle(int x,int y, int xx, int yy)
dhamilton31 2:087e0b0b526c 6 {
dhamilton31 2:087e0b0b526c 7 x1 = x;
dhamilton31 2:087e0b0b526c 8 x2 = xx;
dhamilton31 2:087e0b0b526c 9 y1 = y;
dhamilton31 2:087e0b0b526c 10 y2 = yy;
dhamilton31 2:087e0b0b526c 11 }
projetremote 0:19fca77774b6 12
dhamilton31 2:087e0b0b526c 13 bool Rectangle :: is_touch(int x_touch , int y_touch)
dhamilton31 2:087e0b0b526c 14 {
dhamilton31 2:087e0b0b526c 15 if(x_touch >= x1 && x_touch <= x2) {
dhamilton31 2:087e0b0b526c 16 if(y_touch >= y1 && y_touch <= y2) {
projetremote 0:19fca77774b6 17 return true;
dhamilton31 2:087e0b0b526c 18 }
projetremote 0:19fca77774b6 19 }
dhamilton31 2:087e0b0b526c 20 return false;
dhamilton31 2:087e0b0b526c 21 }
dhamilton31 2:087e0b0b526c 22
dhamilton31 2:087e0b0b526c 23
dhamilton31 2:087e0b0b526c 24 int Rectangle :: getX1()
dhamilton31 2:087e0b0b526c 25 {
dhamilton31 2:087e0b0b526c 26 return x1;
dhamilton31 2:087e0b0b526c 27 }
dhamilton31 2:087e0b0b526c 28
dhamilton31 2:087e0b0b526c 29 int Rectangle :: getX2()
dhamilton31 2:087e0b0b526c 30 {
dhamilton31 1:d9c0709ba2ce 31 return x2;
dhamilton31 2:087e0b0b526c 32 }
dhamilton31 2:087e0b0b526c 33
dhamilton31 2:087e0b0b526c 34 int Rectangle :: getY1()
dhamilton31 2:087e0b0b526c 35 {
dhamilton31 1:d9c0709ba2ce 36 return y1;
dhamilton31 2:087e0b0b526c 37 }
dhamilton31 2:087e0b0b526c 38
dhamilton31 2:087e0b0b526c 39 int Rectangle :: getY2()
dhamilton31 2:087e0b0b526c 40 {
dhamilton31 1:d9c0709ba2ce 41 return y2;
dhamilton31 2:087e0b0b526c 42 }
dhamilton31 2:087e0b0b526c 43
dhamilton31 2:087e0b0b526c 44 int Rectangle :: getCenterX()
dhamilton31 2:087e0b0b526c 45 {
dhamilton31 1:d9c0709ba2ce 46 return x1 + (x2-x1)/2;
dhamilton31 2:087e0b0b526c 47 }
dhamilton31 2:087e0b0b526c 48
dhamilton31 2:087e0b0b526c 49 int Rectangle :: getCenterY()
dhamilton31 2:087e0b0b526c 50 {
dhamilton31 1:d9c0709ba2ce 51 return y1 + (y2-y1)/2;
dhamilton31 2:087e0b0b526c 52 }