1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Simple example that shows HLineAA() usage.
35 static void redraw(GP_Context
*context
)
37 static float param
= 1;
38 static float param2
= 0.01;
40 GP_Pixel b
= GP_RGBToContextPixel(0xbe, 0xbe, 0x9e, context
);
45 for (y
= 0; y
< context
->w
; y
++) {
46 GP_Coord x0
, x1
, l1
, l2
;
54 GP_Pixel p
= GP_RGBToContextPixel(120 - 3 * param
, abs(40 * param
), 0, context
);
56 l2
*= 4.00 * y
/ context
->h
;
60 x0
+= l1
* sin(param2
* y
) + l2
;
61 x1
-= l1
* cos(param2
* y
) + l2
;
63 GP_HLineAA(context
, x0
, x1
, y
<<8, p
);
87 static int pause_flag
= 0;
89 /* Initalize backend */
90 backend
= GP_BackendX11Init(NULL
, 0, 0, 800, 600, "sin AA", 0);
92 if (backend
== NULL
) {
93 fprintf(stderr
, "Failed to initalize backend\n");
100 redraw(backend
->context
);
101 GP_BackendFlip(backend
);
104 GP_BackendPoll(backend
);
108 while (GP_BackendGetEvent(backend
, &ev
)) {
109 if (ev
.type
== GP_EV_KEY
&& ev
.code
== GP_EV_KEY_DOWN
) {
110 switch (ev
.val
.val
) {
113 GP_BackendExit(backend
);
116 pause_flag
= !pause_flag
;