From 59b0a4f74fd358d44c65137e41594fc7dc8a106e Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 14 Feb 2020 00:30:42 +0800 Subject: New scheme for visualizing note velocity. Updated default color scheme for better results. New class smColor, which is going to replace smColorHSVA & smColorRGBA in the future. --- visualization/extrasmeltutils.cpp | 171 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) (limited to 'visualization/extrasmeltutils.cpp') diff --git a/visualization/extrasmeltutils.cpp b/visualization/extrasmeltutils.cpp index c8b3446..2d0a807 100644 --- a/visualization/extrasmeltutils.cpp +++ b/visualization/extrasmeltutils.cpp @@ -196,3 +196,174 @@ void smParticleSystem::updatePS() } void smParticleSystem::renderPS() {for(unsigned i=0;irender();} + +smColor::smColor() +{r=g=b=h=s=v=a=0;} + +void smColor::update_rgb() +{ + auto f=[this](float n){ + float k=fmodf(n+6.0f*this->h,6.0f); + return this->v-this->v*this->s*max(0.0f,min(1.0f,min(k,4.0f-k))); + }; + r=f(5); + g=f(3); + b=f(1); +} +void smColor::update_hsv() +{ + v=max(r,max(g,b)); + float vm=min(r,min(g,b)); + float chroma=v-vm; + if(v-vmEPSF) + { + r=red; + update_hsv(); + } +} +void smColor::setGreen(float green) +{ + if(fabsf(g-green)>EPSF) + { + g=green; + update_hsv(); + } +} +void smColor::setBlue(float blue) +{ + if(fabsf(b-blue)>EPSF) + { + b=blue; + update_hsv(); + } +} +void smColor::setHue(float hue) +{ + if(fabsf(h-hue)>EPSF) + { + h=hue; + update_rgb(); + } +} +void smColor::setSaturation(float saturation) +{ + if(fabsf(s-saturation)>EPSF) + { + s=saturation; + update_rgb(); + } +} +void smColor::setHSLSaturation(float saturation) +{ + float ss=hslSaturation(); + float l=lightness(); + if(fabsf(ss-saturation)>EPSF) + { + ss=saturation; + v=l+ss*min(l,1-l); + if(vEPSF) + { + v=value; + update_rgb(); + } +} +void smColor::setLightness(float lightness) +{ + float ss=hslSaturation(); + float l=this->lightness(); + if(fabsf(l-lightness)>EPSF) + { + l=lightness; + v=l+ss*min(l,1-l); + if(v