Tweak nyan cat's values a bit to make him more interesting
This commit is contained in:
parent
dad22297d1
commit
db26c788f4
@ -18,7 +18,7 @@
|
|||||||
#include "nyancatanalyzer.h"
|
#include "nyancatanalyzer.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s) {
|
|||||||
for (int band=0 ; band<kRainbowBands ; ++band) {
|
for (int band=0 ; band<kRainbowBands ; ++band) {
|
||||||
float* accumulator = &history_[(band+1) * kHistorySize - 1];
|
float* accumulator = &history_[(band+1) * kHistorySize - 1];
|
||||||
for (int i=0 ; i<samples_per_band ; ++i) {
|
for (int i=0 ; i<samples_per_band ; ++i) {
|
||||||
*accumulator += qAbs(s[sample++]);
|
*accumulator += s[sample++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,11 +85,12 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s) {
|
|||||||
|
|
||||||
for (int band=0 ; band<kRainbowBands ; ++band) {
|
for (int band=0 ; band<kRainbowBands ; ++band) {
|
||||||
// Calculate the Y position of this band.
|
// Calculate the Y position of this band.
|
||||||
float y = float(height()) / (kRainbowBands) * (band + 0.5);
|
const float y = float(height()) / (kRainbowBands + 2) * (band + 0.5);
|
||||||
|
const float band_scale = std::pow(2, band);
|
||||||
|
|
||||||
// Add each point in the line.
|
// Add each point in the line.
|
||||||
for (int x=0 ; x<kHistorySize ; ++x) {
|
for (int x=0 ; x<kHistorySize ; ++x) {
|
||||||
*dest = QPointF(px_per_frame * x, y + *source * kPixelScale * (band+1));
|
*dest = QPointF(px_per_frame * x, y + *source * kPixelScale * band_scale);
|
||||||
++ dest;
|
++ dest;
|
||||||
++ source;
|
++ source;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,9 @@ private:
|
|||||||
static const int kCatFrameCount = 5;
|
static const int kCatFrameCount = 5;
|
||||||
static const int kRainbowOverlap = 13;
|
static const int kRainbowOverlap = 13;
|
||||||
|
|
||||||
static const int kHistorySize = 256;
|
static const int kHistorySize = 128;
|
||||||
static const int kRainbowBands = 6;
|
static const int kRainbowBands = 6;
|
||||||
static const float kPixelScale = 0.01;
|
static const float kPixelScale = 0.03;
|
||||||
|
|
||||||
static const int kFrameIntervalMs = 150;
|
static const int kFrameIntervalMs = 150;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user