VividLightの計算式こうじゃん!
VividLightの計算式こうじゃん!
screen 1, 256, 256title "base color : bottom layer"repeat 256y = cntrepeat 256x = cnti = xcolor i, i, ipset x, ylooploopscreen 2, 256, 256title "blend color : top layer"repeat 256y = cntrepeat 256x = cnti = 255 -ycolor i, i, ipset x, ylooploopscreen 0, 256, 256title "final output"repeat 256y = cntrepeat 256x = cntbase_i = double(x) /255.0blend_i = double( 255 -y ) /255.0#if 0// まちがいif ( blend_i < 0.5 ) {final_i = base_i / ( 1.0 - 2.0*blend_i )} else {final_i = 1.0 - ( 1.0-base_i ) / ( 2.0 * ( blend_i - 0.5 ) )}#else// ただしくはこっち// 0除算扱いになってしまうのでガードを適当にif ( blend_i < 0.5 ) {div = ( 2.0 * blend_i )if ( div > 0.0 ) {final_i = 1.0 - ( 1.0-base_i ) / div} else {final_i = 0.0}} else {div = ( 1.0 - 2.0*(blend_i-0.5) )if ( div > 0.0 ) {final_i = base_i / div} else {final_i = 1.0}}#endif// clampfinal_i = limitf( final_i, 0.0 , 1.0 )i = int( 255.0 * final_i )color i, i, ipset x, ylooploop