1 /* Libvisual-plugins - Standard plugins for libvisual
2 *
3 * Copyright (C) 2002, 2003, 2004, 2005, 2006 Dennis Smit <ds@nerds-incorporated.org>
4 *
5 * Authors: Dennis Smit <ds@nerds-incorporated.org>
6 *
7 * $Id: gfx-background.c,v 1.7 2006/01/22 13:25:26 synap Exp $
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include <string.h>
25
26 #include "common.h"
27 #include "screen.h"
28 #include "audio.h"
29 #include "table.h"
30 #include "gfx-misc.h"
31 #include "misc.h"
32 #include "gfx-background.h"
33
_oink_gfx_background_circles_sine(OinksiePrivate * priv,uint8_t * buf,int color,int rotate,int scroll,int stretch,int size)34 void _oink_gfx_background_circles_sine (OinksiePrivate *priv,
35 uint8_t *buf, int color, int rotate, int scroll, int stretch, int size)
36 {
37 int i;
38 int y;
39 int y1;
40 int x;
41 int x1;
42 int tab;
43 int sadd = priv->screen_xysmallest / 2;
44 float sden;
45
46 rotate = abs (rotate);
47 scroll = abs (scroll);
48 stretch = abs (stretch);
49
50 tab = scroll;
51
52 for (i = 0; i < priv->screen_width; i+= 20)
53 {
54 sden = _oink_table_sin[abs (tab % OINK_TABLE_NORMAL_SIZE)];
55 y = (sden * size) + sadd;
56
57 sden = _oink_table_sin[abs ((tab + OINK_TABLE_NORMAL_SIZE / 2) % OINK_TABLE_NORMAL_SIZE)];
58 y1 = (sden * size) + sadd;
59
60 x = i - priv->screen_halfwidth;
61 x1 = x;
62
63 y = y - priv->screen_halfheight;
64 y1 = y1 - priv->screen_halfheight;
65
66 _oink_pixel_rotate (&x, &y, rotate);
67 _oink_pixel_rotate (&x1, &y1, rotate);
68
69 _oink_gfx_circle_filled (priv, buf, color - abs (sden * 20), 15 - abs (sden * 10),
70 x + priv->screen_halfwidth, y + priv->screen_halfheight);
71 _oink_gfx_circle_filled (priv, buf, color - abs (sden * 20), 15 - abs (sden * 10),
72 x1 + priv->screen_halfwidth, y1 + priv->screen_halfheight);
73
74 tab += stretch;
75 }
76 }
77
_oink_gfx_background_circles_filled(OinksiePrivate * priv,uint8_t * buf,int color,int size,int number,int distance,int turn,int x,int y)78 void _oink_gfx_background_circles_filled (OinksiePrivate *priv,
79 uint8_t *buf, int color, int size, int number, int distance, int turn, int x, int y)
80 {
81 int i;
82 int xi;
83 int yi;
84 int adder = OINK_TABLE_NORMAL_SIZE / number;
85 int tab = turn % OINK_TABLE_NORMAL_SIZE;
86
87 if (tab < 0)
88 {
89 tab = OINK_TABLE_NORMAL_SIZE - +tab;
90 tab = tab % OINK_TABLE_NORMAL_SIZE;
91 }
92
93 for (i = 0; i < number; i++)
94 {
95 xi = (_oink_table_sin[tab % OINK_TABLE_NORMAL_SIZE] * distance) + x;
96 yi = (_oink_table_cos[tab % OINK_TABLE_NORMAL_SIZE] * distance) + y;
97
98 tab += adder;
99
100 _oink_gfx_circle_filled (priv, buf, color, size, xi, yi);
101 }
102 }
103
_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)104 void _oink_gfx_background_floaters (OinksiePrivate *priv,
105 uint8_t *buf, int color, int size, int number, int xturn, int yturn, int x, int badd1, int badd2)
106 {
107 int i;
108 int xi;
109 int yi;
110 int xb;
111 int yb;
112 int add1 = 0;
113 int add2 = 0;
114
115 int mul = ((priv->screen_width - 20) / number);
116
117 for (i = 0; i < number; i++)
118 {
119 xi = (_oink_table_sin[(+xturn + add1) % OINK_TABLE_NORMAL_SIZE] * (float) (priv->screen_width / (number + 1)));
120 yi = (_oink_table_cos[(+yturn + add2) % OINK_TABLE_NORMAL_SIZE] * (float) (priv->screen_height / 5));
121
122 xb = xi + (i * mul) + 20;
123 yb = yi + x;
124
125 if (xb > 0 + size || xb < priv->screen_width - size || yb > 0 + size || yb < priv->screen_height - size)
126 _oink_gfx_circle_filled (priv, buf, color, size, xb, yb);
127
128 add1 += badd1;
129 add2 += badd2;
130 }
131 }
132
_oink_gfx_background_ball_shooting(OinksiePrivate * priv,uint8_t * buf,int color,int distance,int xb,int yb,int x,int y)133 void _oink_gfx_background_ball_shooting (OinksiePrivate *priv,
134 uint8_t *buf, int color, int distance, int xb, int yb, int x, int y)
135 {
136 int xi = _oink_line_xory_next_xy (0, distance, x, y, xb, yb);
137 int yi = _oink_line_xory_next_xy (1, distance, x, y, xb, yb);
138
139 _oink_gfx_circle_filled (priv, buf, color, distance >> 1, xi, yi);
140 }
141
_oink_gfx_background_ball_whirling(OinksiePrivate * priv,uint8_t * buf,int color,int size,int dia,int rot,int x,int y)142 void _oink_gfx_background_ball_whirling (OinksiePrivate *priv,
143 uint8_t *buf, int color, int size, int dia, int rot, int x, int y)
144 {
145 int xd;
146 int yd;
147
148 xd = (_oink_table_sin[rot % OINK_TABLE_NORMAL_SIZE] * dia) + x;
149 yd = (_oink_table_cos[rot % OINK_TABLE_NORMAL_SIZE] * dia) + y;
150
151 _oink_gfx_circle_filled (priv, buf, color, size, xd, yd);
152 }
153
_oink_gfx_background_fill(OinksiePrivate * priv,uint8_t * buf,int color)154 void _oink_gfx_background_fill (OinksiePrivate *priv,
155 uint8_t *buf, int color)
156 {
157 visual_mem_set (buf, color, priv->screen_size);
158 }
159
_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)160 void _oink_gfx_background_circles_star (OinksiePrivate *priv,
161 uint8_t *buf, int color, int size, int tentnr, int ballnr, int badd, int turn, int x, int y)
162 {
163 int i;
164 int i2;
165 int sizedef = 0;
166 int sizedefadd = size / ballnr;
167 int sinadd = OINK_TABLE_NORMAL_SIZE / tentnr;
168 int sindef = turn;
169 int bdef = 0;
170 int xd;
171 int yd;
172
173 for (i = 0; i < tentnr; i++)
174 {
175 sizedef = 0;
176
177 bdef = 0;
178 for (i2 = 0; i2 < ballnr; i2++)
179 {
180 xd = (_oink_table_sin[sindef % OINK_TABLE_NORMAL_SIZE] * bdef) + x;
181 yd = (_oink_table_cos[sindef % OINK_TABLE_NORMAL_SIZE] * bdef) + y;
182
183 _oink_gfx_circle_filled (priv, buf, color, size - sizedef, xd, yd);
184
185 bdef += badd;
186 sizedef += sizedefadd;
187 }
188 sindef += sinadd;
189 }
190 }
191
192