Root/
| 1 | /* |
| 2 | * gfx/misc.h - Helper functions for geometry and attributes |
| 3 | * |
| 4 | * Written 2016 by Werner Almesberger |
| 5 | * Copyright 2016 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #ifndef GFX_MISC_H |
| 15 | #define GFX_MISC_H |
| 16 | |
| 17 | #include <stdbool.h> |
| 18 | |
| 19 | |
| 20 | static inline int mxr(int x, int y, const int m[6]) |
| 21 | { |
| 22 | return x * m[1] + y * m[2]; |
| 23 | } |
| 24 | |
| 25 | |
| 26 | static inline int myr(int x, int y, const int m[6]) |
| 27 | { |
| 28 | return x * m[4] + y * m[5]; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | static inline int mx(int x, int y, const int m[6]) |
| 33 | { |
| 34 | return m[0] + mxr(x, y, m); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | static inline int my(int x, int y, const int m[6]) |
| 39 | { |
| 40 | return m[3] + myr(x, y, m); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | unsigned matrix_to_angle(const int m[6]); |
| 45 | bool matrix_is_mirrored(const int m[6]); |
| 46 | int angle_add(int a, int b); |
| 47 | |
| 48 | int rx(int x, int y, int rot); |
| 49 | int ry(int x, int y, int rot); |
| 50 | |
| 51 | #endif /* !GFX_MISC_H */ |
| 52 |
Branches:
master
