Rectangle class

Dependents:   FollowMeBot FollowMeBot FollowMeBot3 FollowMeBot

Fork of Rectangle by Sensovery Company

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Rectangle.cpp Source File

Rectangle.cpp

00001 #include "mbed.h"
00002 #include "Rectangle.h"
00003 
00004 
00005 Rectangle :: Rectangle(int x,int y, int xx, int yy)
00006 {
00007     x1 = x;
00008     x2 = xx;
00009     y1 = y;
00010     y2 = yy;
00011 }
00012 
00013 bool Rectangle :: is_touch(int x_touch , int y_touch)
00014 {
00015     if(x_touch >= x1 && x_touch <= x2) {
00016         if(y_touch >= y1 && y_touch <= y2) {
00017             return true;
00018         }
00019     }
00020     return false;
00021 }
00022 
00023 
00024 int Rectangle :: getX1()
00025 {
00026     return x1;
00027 }
00028 
00029 int Rectangle :: getX2()
00030 {
00031     return x2;
00032 }
00033 
00034 int Rectangle :: getY1()
00035 {
00036     return y1;
00037 }
00038 
00039 int Rectangle :: getY2()
00040 {
00041     return y2;
00042 }
00043 
00044 int Rectangle :: getCenterX()
00045 {
00046     return x1 + (x2-x1)/2;
00047 }
00048 
00049 int Rectangle :: getCenterY()
00050 {
00051     return y1 + (y2-y1)/2;
00052 }