To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / CollidoscopeApp / include / DrawInfo.h @ 2:dd889fff8423

History | View | Annotate | Download (2.13 KB)

1
#pragma once
2

    
3
#include "cinder/Area.h"
4

    
5
class DrawInfo
6
{
7
public:
8

    
9
    DrawInfo( size_t waveIndex ):
10
        mWaveIndex( waveIndex ),
11
        mWindowWidth(0),
12
        mWindowHeight(0),
13
        mSelectionBarHeight(0),
14
        mShrinkFactor(1)
15
    {}
16

    
17
    void reset( const ci::Area &bounds, float shrinkFactor )
18
    {
19
        mWindowWidth = bounds.getWidth();
20
        mWindowHeight = bounds.getHeight();
21
        mSelectionBarHeight = mWindowHeight / NUM_WAVES;
22
        mShrinkFactor = shrinkFactor;
23
    }
24

    
25
        float audioToHeigt(float audioSample) const {
26
        /* clip into range [-1.1] */
27
        if (audioSample < -1.0f) {
28
            audioSample = -1.0f;
29
        }
30
        else if ( audioSample > 1.0f ){
31
            audioSample = 1.0f;
32
        }
33

    
34
        /* map from [-1,1] to [0,1] */
35
                float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1) 
36

    
37
                /* get bottom and add the scaled height */
38
        return ratio * mSelectionBarHeight; //remove  bounds.getY1() bound only needed for size of tier
39
        }
40

    
41
    float getMaxChunkHeight() const 
42
    {
43
        return mSelectionBarHeight * mShrinkFactor;
44
    }
45

    
46
    float getSelectionBarHeight() const
47
    {
48
        return mSelectionBarHeight;
49
    }
50

    
51
    int32_t getWaveCenterY() const
52
    {
53
        if ( mWaveIndex == 0 )
54
            return mWindowHeight * 0.75f + 1;
55
        else
56
            return mWindowHeight / (NUM_WAVES * 2);
57
    }
58

    
59
        int flipY(int y) const 
60
    {
61
        if ( mWaveIndex == 0)
62
                    return mWindowHeight - y /*+ 24*/;
63
        else
64
            return y /*- 24*/;
65
        }
66

    
67
        int flipX(int x) const
68
    {
69
        return x;
70
        }
71

    
72

    
73
    // how much the wave is shrunk on the y axis with respect to the wave's tier 
74
    float getShrinkFactor() const 
75
    {
76
        return mShrinkFactor;
77
    }
78

    
79
    int32_t getWindowWidth() const
80
    {
81
        return mWindowWidth;
82
    }
83

    
84
    int32_t getWindowHeight() const
85
    {
86
        return mWindowHeight;
87
    }
88

    
89
    DrawInfo( const DrawInfo &original ) = delete;
90
    DrawInfo & operator=( const DrawInfo &original ) = delete;
91

    
92
private:
93
    const size_t mWaveIndex;
94

    
95
    int32_t mWindowHeight;
96
    int32_t mWindowWidth;
97
    int32_t mSelectionBarHeight;
98

    
99
    float mShrinkFactor;
100

    
101
};