Mercurial > sdl-ios-xcode
comparison src/video/SDL_blendrect.c @ 3594:c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Fixed line drawing so when blending a sequence of lines there are no overlapping pixels drawn.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 18 Dec 2009 07:41:59 +0000 |
parents | |
children | f7b03b6838cb |
comparison
equal
deleted
inserted
replaced
3593:b931bcfd94a0 | 3594:c8bed77b0386 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997-2009 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Lesser General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2.1 of the License, or (at your option) any later version. | |
9 | |
10 This library 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 GNU | |
13 Lesser General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Lesser General Public | |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 #include "SDL_config.h" | |
23 | |
24 #include "SDL_video.h" | |
25 | |
26 | |
27 int | |
28 SDL_BlendRect(SDL_Surface * dst, const SDL_Rect * rect, | |
29 int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) | |
30 { | |
31 SDL_Rect full_rect; | |
32 SDL_Point points[5]; | |
33 | |
34 if (!dst) { | |
35 SDL_SetError("Passed NULL destination surface"); | |
36 return -1; | |
37 } | |
38 | |
39 /* If 'rect' == NULL, then outline the whole surface */ | |
40 if (!rect) { | |
41 full_rect.x = 0; | |
42 full_rect.y = 0; | |
43 full_rect.w = dst->w; | |
44 full_rect.h = dst->h; | |
45 rect = &full_rect; | |
46 } | |
47 | |
48 points[0].x = rect->x; | |
49 points[0].y = rect->y; | |
50 points[1].x = rect->x+rect->w-1; | |
51 points[1].y = rect->y; | |
52 points[2].x = rect->x+rect->w-1; | |
53 points[2].y = rect->y+rect->h-1; | |
54 points[3].x = rect->x; | |
55 points[3].y = rect->y+rect->h-1; | |
56 points[4].x = rect->x; | |
57 points[4].y = rect->y; | |
58 return SDL_BlendLines(dst, points, 5, blendMode, r, g, b, a); | |
59 } | |
60 | |
61 int | |
62 SDL_BlendRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, | |
63 int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) | |
64 { | |
65 int i; | |
66 | |
67 for (i = 0; i < count; ++i) { | |
68 if (SDL_BlendRect(dst, rects[i], blendMode, r, g, b, a) < 0) { | |
69 return -1; | |
70 } | |
71 } | |
72 return 0; | |
73 } | |
74 | |
75 /* vi: set ts=4 sw=4 expandtab: */ |