public PDFGradientFunction2(PDFColor color0, PDFColor color1, double domainStart, double domainEnd, double exponent) { this.ColorZero = color0; this.ColorOne = color1; this.DomainStart = domainStart; this.DomainEnd = domainEnd; this.Exponent = exponent; }
public void BindingParamToString() { var src = @"<?xml version='1.0' encoding='utf-8' ?> <doc:Document xmlns:doc = 'http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Components.xsd' xmlns:styles = 'http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Styles.xsd' xmlns:data = 'http://www.scryber.co.uk/schemas/core/release/v1/Scryber.Data.xsd' > <Params> <doc:String-Param id='string' ></doc:String-Param> <doc:Int-Param id='int' ></doc:Int-Param> <doc:Color-Param id='color' ></doc:Color-Param> </Params> <Pages> <doc:Section> <Content> <doc:Label id='{@:int}' text='{@:string}' styles:bg-color='{@:color}' ></doc:Label> </Content> </doc:Section> </Pages> </doc:Document>"; using (var reader = new System.IO.StringReader(src)) { var doc = Document.ParseDocument(reader, ParseSourceType.DynamicContent); var color = new Scryber.Drawing.PDFColor(1, 0, 0); var text = "This is the title"; var date = DateTime.Now; var i = 5; doc.Params["color"] = color.ToString(); doc.Params["string"] = text; doc.Params["int"] = i.ToString(); doc.InitializeAndLoad(); doc.DataBind(); //Find the label as the value should be converted to a string. var first = doc.FindAComponentById(i.ToString()) as Label; Assert.IsNotNull(first, "Could not find the label"); //Check that the text matches Assert.AreEqual(text, first.Text, "The first label does not have the correct text value"); //Check that the color matches Assert.AreEqual(color, first.BackgroundColor, "Background colours do not match"); } }
public void SetStrokeColor(PDFColor color) { switch (color.ColorSpace) { case ColorSpace.G: this.Writer.WriteOpCodeS(PDFOpCode.ColorStrokeGrayscaleSpace, color.Gray); break; case ColorSpace.RGB: this.Writer.WriteOpCodeS(PDFOpCode.ColorStrokeRGBSpace, color.Red, color.Green, color.Blue); break; case ColorSpace.HSL: case ColorSpace.LAB: case ColorSpace.Custom: default: throw new ArgumentOutOfRangeException("color.ColorSpace", String.Format(Errors.ColorValueIsNotCurrentlySupported, color.ColorSpace)); } }
public static bool TryParse(string value, out PDFGradientColor color) { color = null; if (null == value) { return(false); } value = value.Trim(); PDFColor colVal = PDFColor.Transparent; double? opacity = null; double? distance = null; if (value.StartsWith("rgba(")) //We have opacity { var end = value.IndexOf(")"); if (end < 0) { return(false); } else if (end >= value.Length - 1) { if (!PDFColor.TryParseRGBA(value, out colVal, out opacity)) { return(false); } } else { var colS = value.Substring(0, end + 1); if (!PDFColor.TryParseRGBA(value, out colVal, out opacity)) { return(false); } value = value.Substring(end + 1).Trim(); if (value.EndsWith("%")) { value = value.Substring(0, value.Length - 1); } double distV; if (double.TryParse(value, out distV)) { distance = distV; } } color = new PDFGradientColor(colVal, distance, opacity); return(true); } else if (value.StartsWith("rgb(")) //We have rbg and maybe a distance { var end = value.IndexOf(")"); if (end == value.Length - 1) { if (!PDFColor.TryParse(value, out colVal)) { return(false); } } else { var colS = value.Substring(0, end); value = value.Substring(end).Trim(); if (value.EndsWith("%")) { value = value.Substring(0, value.Length - 1); } double distV; if (double.TryParse(value, out distV)) { distance = distV; } } color = new PDFGradientColor(colVal, distance, opacity); return(true); } else if (value.IndexOf(" ") > 0) //we have a named or hex color and a distance { var colS = value.Substring(0, value.IndexOf(" ")).Trim(); value = value.Substring(value.IndexOf(" ")).Trim(); if (!PDFColor.TryParse(colS, out colVal)) { return(false); } if (value.EndsWith("%")) { value = value.Substring(0, value.Length - 1); } double distV; if (double.TryParse(value, out distV)) { distance = distV; } color = new PDFGradientColor(colVal, distance, opacity); return(true); } else if (PDFColor.TryParse(value, out colVal)) //we just have a named or hex color { color = new PDFGradientColor(colVal, distance, opacity); return(true); } else //not recognised { return(false); } }
public PDFGradientColor(PDFColor color, double?distance, double?opacity) { this.Color = color; this.Distance = distance; this.Opacity = opacity; }
public PDFGradientColor(PDFColor color) : this(color, null, null) { }
public static bool TryGetColorFromName(string name, out PDFColor color) { color = null; if (string.IsNullOrEmpty(name)) { return(false); } string lower = name.ToLower(); switch (lower) { case ("aqua"): color = PDFColors.Aqua; break; case ("black"): color = PDFColors.Black; break; case ("blue"): color = PDFColors.Blue; break; case ("fuchsia"): color = PDFColors.Fuchsia; break; case ("gray"): color = PDFColors.Gray; break; case ("green"): color = PDFColors.Green; break; case ("lime"): color = PDFColors.Lime; break; case ("maroon"): color = PDFColors.Maroon; break; case ("navy"): color = PDFColors.Navy; break; case ("olive"): color = PDFColors.Olive; break; case ("purple"): color = PDFColors.Purple; break; case ("red"): color = PDFColors.Red; break; case ("silver"): color = PDFColors.Silver; break; case ("teal"): color = PDFColors.Teal; break; case ("white"): color = PDFColors.White; break; case ("yellow"): color = PDFColors.Yellow; break; case ("transparent"): color = PDFColors.Transparent; break; default: break; } return(null != color); }
public PDFGradientFunction2(PDFColor color0, PDFColor color1) : this(color0, color1, 0, 1, 1) { }
public PDFSolidBrush(PDFColor color, double opacity) : this(color, (PDFReal)opacity) { }
public PDFSolidBrush(PDFColor color, PDFReal opacity) { this._col = color; this._op = opacity; }
public PDFSolidBrush(PDFColor color) : this(color, 1) { }
public static PDFSolidBrush Create(PDFColor color) { return(new PDFSolidBrush(color)); }
public PDFDashPen(PDFDash dash, PDFColor color, PDFUnit width) : base(color, width) { this.Dash = dash; }
public PDFSolidPen(PDFColor color, PDFUnit width) : this() { this.Width = width; this.Color = color; }
public static PDFPen Create(PDFColor color, PDFUnit width) { return(new PDFSolidPen(color, width)); }