3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <libx/base.h>
21 void xline (unsigned x1
, unsigned y1
, unsigned x2
, unsigned y2
, unsigned color
)
22 {// x1 = 450, y1 = 200, x1 = 500, y2 = 250 -- ok
23 // x1 = 450, y1 = 250, x1 = 500, y2 = 200 -- spatne
28 /* vektor s(delkax, delkay) */
34 delkax
= (signed) x1
- (signed) x2
;
36 delkax
= (signed) x2
- (signed) x1
;
40 delkay
= (signed) y1
- (signed) y2
;
42 delkay
= (signed) y2
- (signed) y1
;
48 for (b
= y1
; b
<= ((signed) y1
+delkay
); b
++)
49 xpixel (x1
, b
, color
);
55 for (a
= x1
; a
<= ((signed) x1
+delkax
); a
++)
56 xpixel (a
, y1
, color
);
61 /* parametricka rovnice */
67 float x
= (float) x1
+ (float) delkax
* i
* opacnex
;
68 float y
= (float) y1
+ (float) delkay
* i
* opacney
;
70 if (last_x
!= x
&& last_y
!= y
)
71 xpixel ((unsigned) x
, (unsigned) y
, color
);
73 last_x
= (unsigned) x
;
74 last_y
= (unsigned) y
;