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()
61 const int h = 50; // length of line
62 float deviation = 0.2; // how quickly can it change direction
73 const float pi2 = 6.28318;
74 float halfdeviation = deviation / 2;
76 for(i = 0; i < h; i++) x[i] = -1;
83 if (++head == h) head = 0;
86 if (tail == h) tail = 0;
88 // Undraw oldest pixel
89 if (x[tail] != -1) surface->drawPixel(x[tail], y[tail], Colour::BLACK.rgba());
91 dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation;
94 if (direction >= pi2) direction -= pi2;
95 if (direction < 0) direction += pi2;
100 if (fx < 0) fx += screenWidth;
101 if (fx >= screenWidth) fx -= screenWidth;
102 if (fy < 0) fy += screenHeight;
103 if (fy >= screenHeight) fy -= screenHeight;
108 surface->drawPixel(x[head], y[head], Colour::SELECTHIGHLIGHT.rgba());