File: gfx-background.c

package info (click to toggle)
libvisual-plugins 1%3A0.4.0%2Bdfsg1-10
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,576 kB
  • ctags: 1,165
  • sloc: ansic: 9,358; sh: 8,809; cpp: 871; makefile: 220; sed: 16
file content (191 lines) | stat: -rw-r--r-- 5,228 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* Libvisual-plugins - Standard plugins for libvisual
 * 
 * Copyright (C) 2002, 2003, 2004, 2005, 2006 Dennis Smit <ds@nerds-incorporated.org>
 *
 * Authors: Dennis Smit <ds@nerds-incorporated.org>
 *
 * $Id: gfx-background.c,v 1.7 2006/01/22 13:25:26 synap Exp $
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include <string.h>

#include "common.h"
#include "screen.h"
#include "audio.h"
#include "table.h"
#include "gfx-misc.h"
#include "misc.h"
#include "gfx-background.h"

void _oink_gfx_background_circles_sine (OinksiePrivate *priv,
		uint8_t *buf, int color, int rotate, int scroll, int stretch, int size)
{
	int i;
	int y;
	int y1;
	int x;
	int x1;
	int tab;
	int sadd = priv->screen_xysmallest / 2;
	float sden;

	rotate = abs (rotate);
	scroll = abs (scroll);
	stretch = abs (stretch);

	tab = scroll;

	for (i = 0; i < priv->screen_width; i+= 20)
	{
		sden = _oink_table_sin[abs (tab % OINK_TABLE_NORMAL_SIZE)];
		y = (sden * size) + sadd;
		
		sden = _oink_table_sin[abs ((tab + OINK_TABLE_NORMAL_SIZE / 2) % OINK_TABLE_NORMAL_SIZE)];
		y1 = (sden * size) + sadd;
		
		x = i - priv->screen_halfwidth;
		x1 = x;

		y = y - priv->screen_halfheight;
		y1 = y1 - priv->screen_halfheight;

		_oink_pixel_rotate (&x, &y, rotate);
		_oink_pixel_rotate (&x1, &y1, rotate);

		_oink_gfx_circle_filled (priv, buf, color - abs (sden * 20), 15 - abs (sden * 10),
				x + priv->screen_halfwidth, y + priv->screen_halfheight);
		_oink_gfx_circle_filled (priv, buf, color - abs (sden * 20), 15 - abs (sden * 10),
				x1 + priv->screen_halfwidth, y1 + priv->screen_halfheight);
		
		tab += stretch;
	}
}

void _oink_gfx_background_circles_filled (OinksiePrivate *priv,
		uint8_t *buf, int color, int size, int number, int distance, int turn, int x, int y)
{
	int i;
	int xi;
	int yi;
	int adder = OINK_TABLE_NORMAL_SIZE / number;
	int tab = turn % OINK_TABLE_NORMAL_SIZE;

	if (tab < 0)
	{
		tab = OINK_TABLE_NORMAL_SIZE - +tab;
		tab = tab % OINK_TABLE_NORMAL_SIZE;
	}

	for (i = 0; i < number; i++)
	{
		xi = (_oink_table_sin[tab % OINK_TABLE_NORMAL_SIZE] * distance) + x;
		yi = (_oink_table_cos[tab % OINK_TABLE_NORMAL_SIZE] * distance) + y;
		
		tab += adder;
	
		_oink_gfx_circle_filled (priv, buf, color, size, xi, yi); 
	}
}

void _oink_gfx_background_floaters (OinksiePrivate *priv,
		uint8_t *buf, int color, int size, int number, int xturn, int yturn, int x, int badd1, int badd2)
{
	int i;
	int xi;
	int yi;
	int xb;
	int yb;
	int add1 = 0;
	int add2 = 0;
		
	int mul = ((priv->screen_width - 20) / number);
	
	for (i = 0; i < number; i++)
	{
		xi = (_oink_table_sin[(+xturn + add1) % OINK_TABLE_NORMAL_SIZE] * (float) (priv->screen_width / (number + 1)));
		yi = (_oink_table_cos[(+yturn + add2) % OINK_TABLE_NORMAL_SIZE] * (float) (priv->screen_height / 5));

		xb = xi + (i * mul) + 20;
		yb = yi + x;

		if (xb > 0 + size || xb < priv->screen_width - size || yb > 0 + size || yb < priv->screen_height - size)
			_oink_gfx_circle_filled (priv, buf, color, size, xb, yb);

		add1 += badd1;
		add2 += badd2;
	}
}

void _oink_gfx_background_ball_shooting (OinksiePrivate *priv,
		uint8_t *buf, int color, int distance, int xb, int yb, int x, int y)
{
	int xi = _oink_line_xory_next_xy (0, distance, x, y, xb, yb);
	int yi = _oink_line_xory_next_xy (1, distance, x, y, xb, yb);

	_oink_gfx_circle_filled (priv, buf, color, distance >> 1, xi, yi);
}

void _oink_gfx_background_ball_whirling (OinksiePrivate *priv,
		uint8_t *buf, int color, int size, int dia, int rot, int x, int y)
{
	int xd;
	int yd;

	xd = (_oink_table_sin[rot % OINK_TABLE_NORMAL_SIZE] * dia) + x;
	yd = (_oink_table_cos[rot % OINK_TABLE_NORMAL_SIZE] * dia) + y;

	_oink_gfx_circle_filled (priv, buf, color, size, xd, yd);
}

void _oink_gfx_background_fill (OinksiePrivate *priv,
		uint8_t *buf, int color)
{
	visual_mem_set (buf, color, priv->screen_size);
}

void _oink_gfx_background_circles_star (OinksiePrivate *priv,
		uint8_t *buf, int color, int size, int tentnr, int ballnr, int badd, int turn, int x, int y)
{
	int i;
	int i2;
	int sizedef = 0;
	int sizedefadd = size / ballnr;
	int sinadd = OINK_TABLE_NORMAL_SIZE / tentnr;
	int sindef = turn;
	int bdef = 0;
	int xd;
	int yd;

	for (i = 0; i < tentnr; i++)
	{
		sizedef = 0;

		bdef = 0;
		for (i2 = 0; i2 < ballnr; i2++)
		{
			xd = (_oink_table_sin[sindef % OINK_TABLE_NORMAL_SIZE] * bdef) + x;
			yd = (_oink_table_cos[sindef % OINK_TABLE_NORMAL_SIZE] * bdef) + y;

			_oink_gfx_circle_filled (priv, buf, color, size - sizedef, xd, yd);

			bdef += badd;
			sizedef += sizedefadd;
		}
		sindef += sinadd;
	}
}