MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Draw

Method Draw

Source/EnvelopeEditor.cpp:46–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void EnvelopeControl::Draw()
47{
48 ofPushStyle();
49
50 ofSetColor(100, 100, .8f * gModuleDrawAlpha);
51
52 ofSetLineWidth(.5f);
53 ofRect(mPosition.x, mPosition.y, mDimensions.x, mDimensions.y, 0);
54
55 ofSetColor(245, 58, 0, gModuleDrawAlpha);
56
57 if (mAdsr != nullptr)
58 {
59 ADSR::EventInfo adsrEvent(0, GetReleaseTime());
60
61 ofSetLineWidth(1);
62 ofBeginShape();
63 for (float i = 0; i < mDimensions.x; i += (.25f / gDrawScale))
64 {
65 float time = i / mDimensions.x * mViewLength;
66
67 if (time < GetPreSustainTime())
68 {
69 float value = mAdsr->Value(time, &adsrEvent);
70 AddVertex(i + mPosition.x, GetYForValue(value));
71 }
72 else
73 {
74 break;
75 }
76 }
77 AddVertex(GetXForTime(GetPreSustainTime()),
78 GetYForValue(mAdsr->Value(GetPreSustainTime(), &adsrEvent)));
79 ofEndShape(false);
80
81 ofPushStyle();
82 ofSetColor(0, 58, 245, gModuleDrawAlpha);
83 ofLine(ofClamp(GetXForTime(GetPreSustainTime()), mPosition.x, mPosition.x + mDimensions.x),
84 GetYForValue(mAdsr->Value(GetPreSustainTime(), &adsrEvent)),
85 ofClamp(GetXForTime(GetReleaseTime()), mPosition.x, mPosition.x + mDimensions.x),
86 GetYForValue(mAdsr->Value(GetReleaseTime(), &adsrEvent)));
87 ofPopStyle();
88
89 ofBeginShape();
90 AddVertex(GetXForTime(GetReleaseTime()),
91 GetYForValue(mAdsr->Value(GetReleaseTime(), &adsrEvent)));
92 for (float i = 0; i < mDimensions.x; i += (.25f / gDrawScale))
93 {
94 float time = i / mDimensions.x * mViewLength;
95
96 if (time >= GetReleaseTime())
97 {
98 float value = mAdsr->Value(time, &adsrEvent);
99 AddVertex(i + mPosition.x, GetYForValue(value));
100 }
101 }
102 ofEndShape(false);
103

Callers 1

DrawModuleMethod · 0.45

Calls 15

ofPushStyleFunction · 0.85
ofSetColorFunction · 0.85
ofSetLineWidthFunction · 0.85
ofRectFunction · 0.85
ofBeginShapeFunction · 0.85
ofEndShapeFunction · 0.85
ofLineFunction · 0.85
ofClampFunction · 0.85
ofPopStyleFunction · 0.85
ofFillFunction · 0.85
ofNoFillFunction · 0.85
ofCircleFunction · 0.85

Tested by

no test coverage detected