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(DrawStyle::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;
86 DrawStyle &black=DrawStyle::BLACK;
87 DrawStyle &light=DrawStyle::SELECTHIGHLIGHT;
91 if (++head == h) head = 0;
94 if (tail == h) tail = 0;
96 // Undraw oldest point
97 if (x[tail] != -1) surface->drawPoint(x[tail], y[tail], black);// was rgba
99 dd = ((rand() / (double)RAND_MAX) * deviation) - halfdeviation;
102 if (direction >= pi2) direction -= pi2;
103 if (direction < 0) direction += pi2;
105 fx += sin(direction);
106 fy += cos(direction);
108 if (fx < 0) fx += screenWidth;
109 if (fx >= screenWidth) fx -= screenWidth;
110 if (fy < 0) fy += screenHeight;
111 if (fy >= screenHeight) fy -= screenHeight;
116 surface->drawPoint(x[head], y[head], light); // was rgba