void ColorWidget::wheelEvent(QWheelEvent *event) { if(event->delta() > 0) previousColor(); else nextColor(); }
// Because file only specifies a number of control points, a full color table must be made from these control points by linearly interpolating void TransferFunction::LoadLookup(std::vector<glm::vec4> &colorTable) { glm::vec4 previousColor(0.0f); float previousIntensity = 0.0f; int next = 0; for (int i=0; i<256; i++) { float currentIntensity = (float)i / (float)255; while (next < numIntensities && currentIntensity > intensities[next]) { previousIntensity = intensities[next]; previousColor = colors[next]; next++; } if (next < numIntensities) colorTable[i] = LERPColor(previousColor, colors[next], previousIntensity, intensities[next], currentIntensity); else colorTable[i] = LERPColor(previousColor, glm::vec4(0.0f), previousIntensity, 1.0f, currentIntensity); } CopyToTex(colorTable); }
void ColorWidget::mousePressEvent(QMouseEvent * event) { switch(event->button()) { case Qt::LeftButton: nextColor(); break; case Qt::RightButton: previousColor(); break; default:; } }
Color ParticleColorManager::getNewColor(Particle* particle) { Color newColor(calculateColor(redColorCalculation, particle), calculateColor(greenColorCalculation, particle), calculateColor(blueColorCalculation, particle), particle->color.getAlpha()); if (trasitionRunnedSeconds < trasitionLength) { Color previousColor(calculateColor(previousRedColorCalculation, particle), calculateColor(previousGreenColorCalculation, particle), calculateColor(previousBlueColorCalculation, particle), particle->color.getAlpha()); return Gradient::getColorBetween(previousColor, newColor, trasitionLength, trasitionRunnedSeconds); } else return newColor; }
void TransferFunction::loadLookup() { glm::vec4 previousColor(0.0f); float previousIntensity = 0.0f; int next = 0; for (int i=0; i<TRANSFER_FN_TABLE_SIZE; i++) { float currentIntensity = (float)i / (float)255; while (next < m_numIntensities && currentIntensity > m_intensities[next]) { previousIntensity = m_intensities[next]; previousColor = m_colors[next]; next++; } if (next < m_numIntensities) m_colorTable[i] = LERPColor(previousColor, m_colors[next], previousIntensity, m_intensities[next], currentIntensity); else m_colorTable[i] = LERPColor(previousColor, glm::vec4(0.0f), previousIntensity, 1.0f, currentIntensity); } }