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

Method DrawModule

Source/ModulatorExpression.cpp:123–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void ModulatorExpression::DrawModule()
124{
125 if (Minimized() || IsVisible() == false)
126 return;
127
128 ofPushStyle();
129
130 ofPushStyle();
131 ofSetColor(80, 80, 80, 80 * gModuleDrawAlpha);
132 ofFill();
133 ofRect(kGraphX, kGraphY, kGraphWidth, kGraphHeight);
134 ofPopStyle();
135
136 if (!mExpressionValid)
137 {
138 ofSetColor(255, 0, 0, 60);
139 ofFill();
140 ofRect(mTextEntry->GetRect(true));
141 }
142 else
143 {
144 ofPushMatrix();
145 ofClipWindow(kGraphX, kGraphY, kGraphWidth, kGraphHeight, true);
146 ofPushStyle();
147 ofSetColor(0, 255, 0, gModuleDrawAlpha);
148 ofNoFill();
149 ofBeginShape();
150 float drawMinOutput = mLastDrawMinOutput;
151 float drawMaxOutput = mLastDrawMaxOutput;
152 for (int i = 0; i <= kGraphWidth; ++i)
153 {
154 mExpressionInputDraw = ofMap(i, 0, kGraphWidth, mExpressionInputSlider->GetMin(), mExpressionInputSlider->GetMax());
155 float output = mExpressionDraw.value();
156 ofVertex(i + kGraphX, ofMap(output, drawMinOutput, drawMaxOutput, kGraphHeight, 0) + kGraphY);
157
158 if (i == 0)
159 {
160 mLastDrawMinOutput = output;
161 mLastDrawMaxOutput = output;
162 }
163 else
164 {
165 if (output < mLastDrawMinOutput)
166 mLastDrawMinOutput = output;
167 if (output > mLastDrawMaxOutput)
168 mLastDrawMaxOutput = output;
169 }
170 }
171 ofEndShape();
172
173 ofSetColor(245, 58, 135);
174 mExpressionInputDraw = mExpressionInput;
175 ofCircle(kGraphX + ofMap(mExpressionInputDraw, mExpressionInputSlider->GetMin(), mExpressionInputSlider->GetMax(), 0, kGraphWidth), ofMap(mExpressionDraw.value(), mLastDrawMinOutput, mLastDrawMaxOutput, kGraphHeight, 0) + kGraphY, 3);
176 ofPopStyle();
177
178 DrawTextNormal(ofToString(drawMinOutput, 2), kGraphX + kGraphWidth * .35f, kGraphY + kGraphHeight - 1);
179 DrawTextNormal(ofToString(drawMaxOutput, 2), kGraphX + kGraphWidth * .35f, kGraphY + 12);
180 DrawTextNormal(ofToString(mExpressionInputSlider->GetMin()), kGraphX + 1, kGraphY + kGraphHeight / 2 + 6);

Callers

nothing calls this directly

Calls 15

ofPushStyleFunction · 0.85
ofSetColorFunction · 0.85
ofFillFunction · 0.85
ofRectFunction · 0.85
ofPopStyleFunction · 0.85
ofPushMatrixFunction · 0.85
ofClipWindowFunction · 0.85
ofNoFillFunction · 0.85
ofBeginShapeFunction · 0.85
ofMapFunction · 0.85
ofVertexFunction · 0.85
ofEndShapeFunction · 0.85

Tested by

no test coverage detected