GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
core
gp_transform.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/*
3
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos
4
* <jiri.bluebear.dluhos@gmail.com>
5
*
6
* Copyright (C) 2009-2024 Cyril Hrubis <metan@ucw.cz>
7
*
8
* Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz>
9
*/
10
20
#ifndef CORE_GP_TRANSFORM_H
21
#define CORE_GP_TRANSFORM_H
22
23
#include <
core/gp_common.h
>
24
33
#define GP_TRANSFORM_X(pixmap, x) do { \
34
if ((pixmap)->x_swap) \
35
x = (pixmap)->w - x - 1; \
36
} while (0)
37
46
#define GP_TRANSFORM_Y(pixmap, y) do { \
47
if ((pixmap)->y_swap) \
48
y = (pixmap)->h - y - 1; \
49
} while (0)
50
60
#define GP_TRANSFORM_SWAP(pixmap, x, y) do { \
61
if ((pixmap)->axes_swap) \
62
GP_SWAP(x, y); \
63
} while (0)
64
78
#define GP_TRANSFORM_POINT(pixmap, x, y) do { \
79
GP_TRANSFORM_SWAP(pixmap, x, y); \
80
GP_TRANSFORM_X(pixmap, x); \
81
GP_TRANSFORM_Y(pixmap, y); \
82
} while (0)
83
95
#define GP_TRANSFORM_RECT(pixmap, x, y, w, h) do { \
96
GP_TRANSFORM_SWAP(pixmap, x, y); \
97
GP_TRANSFORM_SWAP(pixmap, w, h); \
98
\
99
if ((pixmap)->x_swap) \
100
x = (pixmap)->w - x - w; \
101
\
102
if ((pixmap)->y_swap) \
103
y = (pixmap)->h - y - h; \
104
} while (0)
105
106
/*
107
* Transform "user"-coordinates to "real"-coordinates for a blit
108
* called as gp_blit(c1, x1, y1, w, h, c2, x2, y2).
109
* All x1, y1, x2, y2, w, h are adjusted.
110
*/
111
#define GP_TRANSFORM_BLIT(c1, x1, y1, w, h, c2, x2, y2) do { \
112
GP_TRANSFORM_RECT(c1, x1, y1, w, h); \
113
int w2 = w, h2 = h; \
114
GP_TRANSFORM_SWAP(c2, w2, h2); \
115
GP_TRANSFORM_RECT(c2, x2, y2, w2, h2); \
116
} while (0)
117
129
#define GP_RETRANSFORM_POINT(pixmap, x, y) do { \
130
GP_TRANSFORM_X(pixmap, x); \
131
GP_TRANSFORM_Y(pixmap, y); \
132
GP_TRANSFORM_SWAP(pixmap, x, y); \
133
} while (0)
134
135
#endif
/* CORE_GP_TRANSFORM_H */
gp_common.h
Common macros.
Generated by
1.9.8