private static ColorF MaseyaBlend(ColorF x, ColorF y) { // Ensure at least a 2.5% change in hue. var hue = (y.Red * 0.95f) + 0.025f + x.Hue; var chromaShift = y.Green - 0.5f; var chroma = x.Chroma; if (chromaShift > 0) { // Put heavy limitations on oversaturating colors. chroma *= 1.0f + ((1.0f - chroma) * chromaShift * 0.5f); } else { // Put no limitation on desaturating colors. However, make it // more likely that only a little desaturation will occur. chroma *= (float)Pow(1 - Pow(chromaShift * 2, 2), 0.5); } var lumaShift = y.Blue - 0.5f; var luma = x.Luma; if (lumaShift > 0) { // Do not heavily brighten colors. However, if we removed a // lot of saturation, then we can allow for some brighter // colors. var chromaDiff = Max(x.Chroma - chroma, 0); luma *= 1.0f + ((1.0f - x.Luma) * lumaShift * (1.0f + chromaDiff)); } else { // Do not let colors get too dark. luma *= 1.0f + (lumaShift / 2.0f); } var result = ColorF.FromHcy( hue, chroma, luma); return(result); }