diff --git a/Source/DrawComponent.cpp b/Source/DrawComponent.cpp index 0c5b37f..442ca44 100644 --- a/Source/DrawComponent.cpp +++ b/Source/DrawComponent.cpp @@ -233,19 +233,19 @@ RowVectorXd& DrawComponent::getData () void DrawComponent::DrawData () { - RowVectorXd temp = m_data; - - for (int i=0; i < m_width*m_height; i++) + double max = m_data.array().abs().maxCoeff(); + + if (max < 1.0) { - temp[i] = std::min(1.0, (double)temp[i]); - temp[i] = std::max(-1.0, (double)temp[i]); + max = 1.0; } - + double scale = m_scale/max; + for (int i=0; i < m_height; i++) { for (int j=0; j < m_width; j++) { - m_pG->setColour(Colour(Colours::white).greyLevel(m_offset + m_scale*temp[i*m_width + j])); + m_pG->setColour(Colour(Colours::white).greyLevel(m_offset + scale*m_data[i*m_width + j])); m_pG->fillRect(m_scaleX*j, m_scaleY*i, m_scaleX, m_scaleY); } }