1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef NYANCATANALYZER_H
19
#define NYANCATANALYZER_H
21
#include "analyzerbase.h"
25
class NyanCatAnalyzer : public Analyzer::Base {
29
Q_INVOKABLE NyanCatAnalyzer(QWidget* parent);
31
static const char* kName;
34
void transform(Scope&);
35
void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
37
void timerEvent(QTimerEvent* e);
38
void resizeEvent(QResizeEvent* e);
41
static const int kCatHeight = 21;
42
static const int kCatWidth = 34;
43
static const int kCatFrameCount = 5;
44
static const int kRainbowOverlap = 13;
46
static const int kHistorySize = 128;
47
static const int kRainbowBands = 6;
48
static const float kPixelScale;
50
static const int kFrameIntervalMs = 150;
53
inline QRect CatSourceRect() const {
54
return QRect(0, kCatHeight * frame_, kCatWidth, kCatHeight);
58
// "constants" that get initialised in the constructor
59
float band_scale_[kRainbowBands];
60
QPen colors_[kRainbowBands];
65
// For the nyan cat animation
69
// The y positions of each point on the rainbow.
70
float history_[kHistorySize * kRainbowBands];
72
// A cache of the last frame's rainbow, so it can be used in the next frame.
76
// Geometry information that's updated on resize:
77
// The width of the widget minus the space for the cat
78
int available_rainbow_width_;
80
// X spacing between each point in the polyline.
83
// Amount the buffer_ is shifted to the left (off the edge of the widget) to
84
// make the rainbow extend from 0 to available_rainbow_width_.
87
QBrush background_brush_;
90
#endif // NYANCATANALYZER_H