| 121 | } |
| 122 | |
| 123 | void 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); |
nothing calls this directly
no test coverage detected