public async Task <string> getClosestWindowsColor() { Debug.WriteLine("TCS34725::GetClosestColor"); RgbData rgbData = await getRgbData(); KnownColor closestColor = colorList[7]; double minDiff = double.MaxValue; foreach (var c in colorList) { Color cValue = c.colorValue; double diff = Math.Pow((cValue.R - rgbData.Red), 2) + Math.Pow((cValue.G - rgbData.Green), 2) + Math.Pow((cValue.B - rgbData.Blue), 2); diff = (int)Math.Sqrt(diff); if (diff < minDiff) { minDiff = diff; closestColor = c; } } Debug.WriteLine(string.Format("Approx Color: {0}\r\nValue: {1}", closestColor.colorName, closestColor.colorValue)); return(closestColor.colorName); }
public async Task <ColorfulRestProperty> getColorfulRestData() { Debug.WriteLine("TCS34725::GetColorfulRestData"); RgbData rgbData = await getRgbData(); object json = await ApiHelpers.getColorApiJson(rgbData.Red, rgbData.Green, rgbData.Blue); return(new ColorfulRestProperty(json)); }
public async Task <RgbData> getRgbData() { Debug.WriteLine("TCS34725::getRgbData"); RgbData rgbData = new RgbData(); ColorData rawColor = await getRawData(); if (rawColor.Clear > 0) { rgbData.Red = (rawColor.Red * 255 / rawColor.Clear); rgbData.Green = (rawColor.Green * 255 / rawColor.Clear); rgbData.Blue = (rawColor.Blue * 255 / rawColor.Clear); } Debug.WriteLine(string.Format("RGB Data - Red: {0}, Green: {1}, Blue: {2}", rgbData.Red, rgbData.Green, rgbData.Blue)); return(rgbData); }
public async Task<RgbData> getRgbData() { Debug.WriteLine("TCS34725::getRgbData"); RgbData rgbData = new RgbData(); ColorData rawColor = await getRawData(); if (rawColor.Clear > 0) { rgbData.Red = (rawColor.Red * 255 / rawColor.Clear); rgbData.Green = (rawColor.Green * 255 / rawColor.Clear); rgbData.Blue = (rawColor.Blue * 255 / rawColor.Clear); } Debug.WriteLine(string.Format("RGB Data - Red: {0}, Green: {1}, Blue: {2}", rgbData.Red, rgbData.Green, rgbData.Blue)); return rgbData; }