summaryrefslogtreecommitdiff
path: root/Gfx.c
diff options
context:
space:
mode:
authorerdgeist <>2003-05-13 12:05:12 +0000
committererdgeist <>2003-05-13 12:05:12 +0000
commit866f0ad8030ea2ceea22a4d61e6ff0006546c3fa (patch)
tree54f3af1248bce246e1dd92b196b818271d21f2f6 /Gfx.c
Here we go
Diffstat (limited to 'Gfx.c')
-rwxr-xr-xGfx.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/Gfx.c b/Gfx.c
new file mode 100755
index 0000000..1145f9a
--- /dev/null
+++ b/Gfx.c
@@ -0,0 +1,65 @@
1#include "Gfx.h"
2#include "Kullers.h"
3
4static void *bitmap = (void*)0;
5unsigned long g_width, g_height;
6unsigned long minx, miny, maxx, maxy;
7
8void Gfx_init( void *offscreen, int width, int height ) {
9 maxx = g_width = width;
10 maxy = g_height = height;
11 bitmap = offscreen;
12 minx = miny = 0;
13}
14
15void Gfx_destroy( void ) {
16// if( bitmap )
17// free( bitmap );
18}
19
20void Gfx_clear( void ) {
21 unsigned long *dest = ((unsigned long *)bitmap) + miny * g_width + minx;
22 int nochy = maxy - miny;
23
24 while( nochy-- ) {
25 memset( dest, 0, (maxx - minx) << 2);
26 dest += g_width;
27 }
28
29 minx = g_width; miny = g_height;
30 maxx = 0; maxy = 0;
31}
32
33int getkulleroff( int radius ) {
34 int sum = 0;
35 while( --radius>0 )
36 sum += radius*radius;
37 return sum;
38}
39
40void Gfx_kuller( int x, int y, int radius, unsigned long r, unsigned long g, unsigned long b ) {
41 unsigned long *dest = ((unsigned long *)bitmap) + y * g_width + x;
42 unsigned char *src = Kullers + getkulleroff( radius ) - 1;
43 int xoffs = g_width - radius;
44 int nochy = radius;
45
46 if( minx > x ) minx = x;
47 if( miny > y ) miny = y;
48 if( maxx < x + radius ) maxx = x + radius;
49 if( maxy < y + radius ) maxy = y + radius;
50
51 while( nochy-- >0 ) {
52 int nochx = radius;
53 while( nochx-- >0 ) {
54 if( *(++src) ) {
55 int this_r = ((r * (int)*src) >> 8);
56 int this_g = ((g * (int)*src) >> 8);
57 int this_b = ((b * (int)*src) >> 8);
58 *(dest++) = (this_r<<16) | (this_g<<8) | this_b;
59 } else {
60 dest++;
61 }
62 }
63 dest += xoffs;
64 }
65}