7 changed files with 126 additions and 13 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> |
||||
* |
||||
* This file is part of ZToolkit |
||||
* |
||||
* ZToolkit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* ZToolkit is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Affero Public License |
||||
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef __ZTOOLKIT_MATH_H__ |
||||
#define __ZTOOLKIT_MATH_H__ |
||||
|
||||
#include <float.h> |
||||
#include <math.h> |
||||
|
||||
#define math_doubles_equal(a,b) \ |
||||
(a > b ? a - b < DBL_EPSILON : b - a < DBL_EPSILON) |
||||
|
||||
#endif |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> |
||||
* |
||||
* This file is part of ZToolkit |
||||
* |
||||
* ZToolkit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* ZToolkit is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Affero Public License |
||||
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#ifndef __ZTOOLKIT_RECT_H__ |
||||
#define __ZTOOLKIT_RECT_H__ |
||||
|
||||
/**
|
||||
* Wrapper over PuglRect. |
||||
*/ |
||||
typedef struct ZtkRect |
||||
{ |
||||
double x; |
||||
double y; |
||||
double width; |
||||
double height; |
||||
} ZtkRect; |
||||
|
||||
int |
||||
ztk_rect_is_equal ( |
||||
ZtkRect * src, |
||||
ZtkRect * dest); |
||||
|
||||
void |
||||
ztk_rect_copy ( |
||||
ZtkRect * dest, |
||||
ZtkRect * src); |
||||
|
||||
#endif |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> |
||||
* |
||||
* This file is part of ZToolkit |
||||
* |
||||
* ZToolkit is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as |
||||
* published by the Free Software Foundation, either version 3 of the |
||||
* License, or (at your option) any later version. |
||||
* |
||||
* ZToolkit is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Affero Public License |
||||
* along with ZToolkit. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#include "ztoolkit/math.h" |
||||
#include "ztoolkit/rect.h" |
||||
|
||||
int |
||||
ztk_rect_is_equal ( |
||||
ZtkRect * src, |
||||
ZtkRect * dest) |
||||
{ |
||||
return |
||||
math_doubles_equal ( |
||||
src->x, dest->x) && |
||||
math_doubles_equal ( |
||||
src->y, dest->y) && |
||||
math_doubles_equal ( |
||||
src->width, dest->width) && |
||||
math_doubles_equal ( |
||||
src->height, dest->height); |
||||
} |
||||
|
||||
void |
||||
ztk_rect_copy ( |
||||
ZtkRect * dest, |
||||
ZtkRect * src) |
||||
{ |
||||
dest->x = src->x; |
||||
dest->y = src->y; |
||||
dest->width = src->width; |
||||
dest->height = src->height; |
||||
} |
Loading…
Reference in new issue