protected override Node EditColor(Color color, Number number) { var value = number.Value; if (number.Unit == "%") value = (value * 255) / 100d; return new Color(color.R, color.G, color.B + value); }
protected override Node EditColor(Color color, Number number) { var alpha = number.Value; if (number.Unit == "%") alpha = alpha / 100d; return new Color(color.R, color.G, color.B, color.Alpha + alpha); }
protected override Node Eval(Number number, Node[] args) { if (number.Unit == "%") return number; if (string.IsNullOrEmpty(number.Unit)) return new Number(number.Value * 100, "%"); throw new ParsingException(string.Format("Expected unitless number in function 'percentage', found {0}", number.ToCSS(null))); }
protected abstract Node EditHsl(HslColor color, Number number);
protected override Node EditColor(Color color, Number number) { var hsl = HslColor.FromRgbColor(color); return EditHsl(hsl, number); }
protected override Node EditHsl(HslColor color, Number number) { color.Saturation += number.Value / 100; return color.ToRgbColor(); }
protected override Node EditHsl(HslColor color, Number number) { color.Lightness += number.Value / 100; return color.ToRgbColor(); }
protected override Node EditHsl(HslColor color, Number number) { color.Hue += number.Value / 360d; return color.ToRgbColor(); }
protected override Node EditHsl(HslColor color, Number number) { return null; }
protected abstract Node Eval(Number number, Node[] args);
protected virtual Node EditColor(Color color, Number number) { return null; }