public ActionResult Test([Bind(Include = "ColorName,EnteredName")] ColorResult result) { if (ModelState.IsValid && result.EnteredName != null && result.ColorName.Length > 0) { if (ColorExercises.Test(result.ColorName, result.EnteredName)) { return(RedirectToAction("Test", new { @continue = true })); } else { Color color = cr.Color(result.ColorName); return(RedirectToAction("WrongAnswer", new ColorWrongAnswerVM { EnteredName = result.EnteredName, ColorName = color.Name, })); } } else { ViewBag.ColorList = cr.Color(result.ColorName); ViewBag.NbTests = ColorExercises.NB_TESTS; ViewBag.NoTest = ColorExercises.NoTest; ViewBag.Score = ColorExercises.Score; return(View(result)); } }
public IResult Create(float res) { var result = new ColorResult(); result.CountResult = res; result.Color = res % 2 == 0 ? "green" : "red"; return(result); }
public async Task <ActionResult <ColorResult> > Get() { ColorResult result = new ColorResult(); result.success = true; result.responseMessage = "These colors you could used as your entity colors."; result.colors = ColourValues.ToList <string>(); return(result); }
private void Backpropagate(ColorResult cr) { _visits++; if (cr == ColorResult.RedWins) { _redScore++; } else if (cr == ColorResult.Tie) { _redScore += 0.5f; } _parent?.Backpropagate(cr); }
private static ColorResult ConvertCMYK(ColorSpace resultSpace, ColorSource source) { ColorResult color; double c = source.component0; double m = source.component1; double y = source.component2; double k = source.component3; switch (resultSpace) { case ColorSpace.RGBSpace: RGB rgb = ColorConverter.CMYKtoRGB(c, m, y, k); color = new ColorResult(rgb.Red, rgb.Green, rgb.Blue); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.CMYKtoHSB(c, m, y, k); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.HSLSpace: HSL hsl = ColorConverter.CMYKtoHSL(c, m, y, k); color = new ColorResult(hsl.Hue, hsl.Saturation, hsl.Luminance); break; case ColorSpace.LabSpace: Lab lab = ColorConverter.CMYKtoLab(c, m, y, k); color = ScaleCIELabOutputRange(lab); break; case ColorSpace.XYZSpace: XYZ xyz = ColorConverter.CMYKtoXYZ(c, m, y, k); color = new ColorResult(xyz.X, xyz.Y, xyz.Z); break; case ColorSpace.GraySpace: color = new ColorResult(ColorConverter.CMYKtoRGB(c, m, y, k).GetIntensity(source.maxChannelValue)); break; default: throw new InvalidEnumArgumentException("Unsupported color space conversion", (int)resultSpace, typeof(ColorSpace)); } return(color); }
private static ColorResult ConvertXYZ(ColorSpace resultSpace, ColorSource source) { ColorResult color; double x = source.component0; double y = source.component1; double z = source.component2; switch (resultSpace) { case ColorSpace.RGBSpace: RGB rgb = ColorConverter.XYZtoRGB(x, y, z); color = new ColorResult(rgb.Red, rgb.Green, rgb.Blue); break; case ColorSpace.CMYKSpace: CMYK cmyk = ColorConverter.XYZtoCMYK(x, y, z); color = new ColorResult(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.XYZtoHSB(x, y, z); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.HSLSpace: HSL hsl = ColorConverter.XYZtoHSL(x, y, z); color = new ColorResult(hsl.Hue, hsl.Saturation, hsl.Luminance); break; case ColorSpace.LabSpace: Lab lab = ColorConverter.XYZtoLab(x, y, z); color = ScaleCIELabOutputRange(lab); break; case ColorSpace.GraySpace: color = new ColorResult(ColorConverter.XYZtoRGB(x, y, z).GetIntensity(source.maxChannelValue)); break; default: throw new InvalidEnumArgumentException("Unsupported color space conversion", (int)resultSpace, typeof(ColorSpace)); } return(color); }
private static ColorResult ConvertLAB(ColorSpace resultSpace, ColorSource source) { ColorResult color; double l = source.component0; double a = source.component1; double b = source.component2; switch (resultSpace) { case ColorSpace.RGBSpace: RGB rgb = ColorConverter.LabtoRGB(l, a, b); color = new ColorResult(rgb.Red, rgb.Green, rgb.Blue); break; case ColorSpace.CMYKSpace: CMYK cmyk = ColorConverter.LabtoCMYK(l, a, b); color = new ColorResult(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.LabtoHSB(l, a, b); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.HSLSpace: HSL hsl = ColorConverter.LabtoHSL(l, a, b); color = new ColorResult(hsl.Hue, hsl.Saturation, hsl.Luminance); break; case ColorSpace.XYZSpace: XYZ xyz = ColorConverter.LabtoXYZ(l, a, b); color = new ColorResult(xyz.X, xyz.Y, xyz.Z); break; case ColorSpace.GraySpace: color = new ColorResult(ColorConverter.LabtoRGB(l, a, b).GetIntensity(source.maxChannelValue)); break; default: throw new InvalidEnumArgumentException("Unsupported color space conversion", (int)resultSpace, typeof(ColorSpace)); } return(color); }
private static ColorResult ConvertRGB(ColorSpace resultSpace, ColorSource source) { ColorResult color; double red = source.component0; double green = source.component1; double blue = source.component2; switch (resultSpace) { case ColorSpace.CMYKSpace: CMYK cmyk = ColorConverter.RGBtoCMYK(red, green, blue); color = new ColorResult(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black); break; case ColorSpace.GraySpace: color = new ColorResult(ColorConverter.GetRGBIntensity(red, green, blue, source.maxChannelValue)); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.RGBtoHSB(red, green, blue); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.HSLSpace: HSL hsl = ColorConverter.RGBtoHSL(red, green, blue); color = new ColorResult(hsl.Hue, hsl.Saturation, hsl.Luminance); break; case ColorSpace.LabSpace: Lab lab = ColorConverter.RGBtoLab(red, green, blue); color = ScaleCIELabOutputRange(lab); break; case ColorSpace.XYZSpace: XYZ xyz = ColorConverter.RGBtoXYZ(red, green, blue); color = new ColorResult(xyz.X, xyz.Y, xyz.Z); break; default: throw new InvalidEnumArgumentException("Unsupported color space conversion", (int)resultSpace, typeof(ColorSpace)); } return(color); }
private static ColorResult ConvertHSL(ColorSpace resultSpace, ColorSource source) { ColorResult color; double h = source.component0; double s = source.component1; double l = source.component2; switch (resultSpace) { case ColorSpace.RGBSpace: RGB rgb = ColorConverter.HSLtoRGB(h, s, l); color = new ColorResult(rgb.Red, rgb.Green, rgb.Blue); break; case ColorSpace.CMYKSpace: CMYK cmyk = ColorConverter.HSLtoCMYK(h, s, l); color = new ColorResult(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.HSLtoHSB(h, s, l); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.LabSpace: Lab lab = ColorConverter.HSLToLab(h, s, l); color = ScaleCIELabOutputRange(lab); break; case ColorSpace.XYZSpace: XYZ xyz = ColorConverter.HSLtoXYZ(h, s, l); color = new ColorResult(xyz.X, xyz.Y, xyz.Z); break; case ColorSpace.GraySpace: color = new ColorResult(ColorConverter.HSLtoRGB(h, s, l).GetIntensity(source.maxChannelValue)); break; default: throw new InvalidEnumArgumentException(nameof(resultSpace), (int)resultSpace, typeof(ColorSpace)); } return(color); }
private static ColorResult ConvertGray(ColorSpace resultSpace, ColorSource source) { ColorResult color; double gray = source.component0; switch (resultSpace) { case ColorSpace.RGBSpace: color = new ColorResult(gray, gray, gray); break; case ColorSpace.CMYKSpace: CMYK cmyk = ColorConverter.RGBtoCMYK(gray, gray, gray); color = new ColorResult(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black); break; case ColorSpace.HSBSpace: HSB hsb = ColorConverter.RGBtoHSB(gray, gray, gray); color = new ColorResult(hsb.Hue, hsb.Saturation, hsb.Brightness); break; case ColorSpace.HSLSpace: HSL hsl = ColorConverter.RGBtoHSL(gray, gray, gray); color = new ColorResult(hsl.Hue, hsl.Saturation, hsl.Luminance); break; case ColorSpace.LabSpace: Lab lab = ColorConverter.RGBtoLab(gray, gray, gray); color = ScaleCIELabOutputRange(lab); break; case ColorSpace.XYZSpace: XYZ xyz = ColorConverter.RGBtoXYZ(gray, gray, gray); color = new ColorResult(xyz.X, xyz.Y, xyz.Z); break; default: throw new InvalidEnumArgumentException(nameof(resultSpace), (int)resultSpace, typeof(ColorSpace)); } return(color); }