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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vscreensaver.h"
30 VScreensaver::VScreensaver()
33 Video* video = Video::getInstance();
34 screenWidth = video->getScreenWidth();
35 screenHeight = video->getScreenHeight();
37 area.h = screenHeight;
38 surface = Surface::getScreen();
41 VScreensaver::~VScreensaver()
43 surface = NULL; // it's the screen. stop view base from killing it.
47 void VScreensaver::draw()
49 fillColour(Colour::BLACK);
53 int VScreensaver::handleCommand(int command)
59 void VScreensaver::threadMethod()
66 const int h = 50; // length of line
67 float deviation = 0.2; // how quickly can it change direction
78 const float pi2 = 6.28318;
79 float halfdeviation = deviation / 2;
81 for(i = 0; i < h; i++) x[i] = -1;
88 if (++head == h) head = 0;
91 if (tail == h) tail = 0;
93 // Undraw oldest pixel
94 if (x[tail] != -1) surface->drawPixel(x[tail], y[tail], Colour::BLACK.rgba());
96 dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation;
99 if (direction >= pi2) direction -= pi2;
100 if (direction < 0) direction += pi2;
102 fx += sin(direction);
103 fy += cos(direction);
105 if (fx < 0) fx += screenWidth;
106 if (fx >= screenWidth) fx -= screenWidth;
107 if (fy < 0) fy += screenHeight;
108 if (fy >= screenHeight) fy -= screenHeight;
113 surface->drawPixel(x[head], y[head], Colour::SELECTHIGHLIGHT.rgba());