private ColorWithAlpha TrySetRGBAValues(CmdArgs args, ColorWithAlpha color) { var numberOfArgs = args.Length; if (numberOfArgs == 4) { SetColorAndAlpha(args, color); } else if (numberOfArgs == 3) { SetColor(args, color); } else if (numberOfArgs == 1) { SetAlpha(args, color, 0); } else { throw new FormatException($"Number of arguments must be 4, 3, or 1. You provided {numberOfArgs}!"); } return(color); }
private void SetAlpha(CmdArgs args, ColorWithAlpha color, int position) { color.Alpha = TryGetArgumentValue(args, position); }
private void SetColor(CmdArgs args, ColorWithAlpha color) { color.Red = TryGetArgumentValue(args, 0); color.Green = TryGetArgumentValue(args, 1); color.Blue = TryGetArgumentValue(args, 2); }
private void SetColorAndAlpha(CmdArgs args, ColorWithAlpha color) { SetColor(args, color); SetAlpha(args, color, 3); }