2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vscreensaver.h"
23 VScreensaver::VScreensaver()
26 Video* video = Video::getInstance();
27 screenWidth = video->getScreenWidth();
28 screenHeight = video->getScreenHeight();
30 area.h = screenHeight;
31 surface = Surface::getScreen();
34 VScreensaver::~VScreensaver()
36 surface = NULL; // it's the screen. stop view base from killing it.
40 void VScreensaver::draw()
42 setBackgroundColour(Colour::BLACK);
47 int VScreensaver::handleCommand(int command)
54 void VScreensaver::threadMethod()
59 int h = 50; // length of line
60 float deviation = 0.2; // how quickly can it change direction
71 const float pi = 3.14159;
72 const float pi2 = 6.28318;
73 float halfdeviation = deviation / 2;
75 for(i = 1; i < h; i++)
86 // Undraw oldest pixel
87 if ((x[h-1] != -1) && (y[h-1] != -1))
89 surface->drawPixel(x[h-1], y[h-1], Colour::BLACK.rgba());
92 for(i = h - 1; i > 0; i--)
98 dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation;
101 if (direction >= pi2) direction -= pi2;
102 if (direction < 0) direction += pi2;
104 fx += sin(direction);
105 fy += cos(direction);
107 if (fx < 0) fx += screenWidth;
108 if (fx >= screenWidth) fx -= screenWidth;
109 if (fy < 0) fy += screenHeight;
110 if (fy >= screenHeight) fy -= screenHeight;
115 surface->drawPixel(x[0], y[0], Colour::SELECTHIGHLIGHT.rgba());