internal void SelectBrush(TPdfStream DataStream, PathGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, PointF CenterPoint, string DrawingMatrix) { ColorBlend cb = null; try { cb = aBrush.InterpolationColors; } catch (ArgumentException)//Awful way to tell if it has InterpolationColors, but the framework does not give us a choice. { } if (cb == null || cb.Colors.Length == 1) { cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.SurroundColors[0], aBrush.CenterColor); } int n = cb.Colors.Length - 1; if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255) { ColorBlend TransparencyBlend = new ColorBlend(2); TransparencyBlend.Colors[0] = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A); TransparencyBlend.Positions[0] = 0; TransparencyBlend.Colors[1] = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A); TransparencyBlend.Positions[1] = 1; TPdfGradient SMask = Resources.GetGradient(TGradientType.Radial, TransparencyBlend, Rect, aBrush.CenterPoint, RotatedCoords, DrawingMatrix); SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true)); } Resources.SelectGradient(DataStream, TGradientType.Radial, cb, Rect, CenterPoint, RotatedCoords, DrawingMatrix); }
public int CompareTo(object obj) { TPdfGradient p2 = obj as TPdfGradient; if (p2 == null) { return(-1); } int Result = GradientType.CompareTo(p2.GradientType); if (Result != 0) { return(Result); } Result = CompareCoords(Coords, p2.Coords); if (Result != 0) { return(Result); } Result = CompareCoords(RotatedCoords, p2.RotatedCoords); if (Result != 0) { return(Result); } if (GradientType == TGradientType.Radial) { Result = CenterPoint.X.CompareTo(p2.CenterPoint.X); if (Result != 0) { return(Result); } Result = CenterPoint.Y.CompareTo(p2.CenterPoint.Y); if (Result != 0) { return(Result); } } Result = BlendFunction.CompareTo(p2.BlendFunction); if (Result != 0) { return(Result); } Result = String.Compare(DrawingMatrix, p2.DrawingMatrix); if (Result != 0) { return(Result); } return(0); }
internal TPdfGradient GetGradient(TGradientType aGradientType, ColorBlend aBlendColors, RectangleF aCoords, PointF aCenterPoint, RectangleF RotatedCoords, string DrawingMatrix) { TPdfGradient SearchGradient = new TPdfGradient(GradientPatterns.Count, aGradientType, aBlendColors, aCoords, aCenterPoint, RotatedCoords, DrawingMatrix, Functions); int Index = GradientPatterns.BinarySearch(0, GradientPatterns.Count, SearchGradient, null); //Only BinarySearch compatible with CF. if (Index < 0) GradientPatterns.Insert(~Index, SearchGradient); else SearchGradient = GradientPatterns[Index]; return SearchGradient; }
internal void SelectBrush(TPdfStream DataStream, LinearGradientBrush aBrush, RectangleF Rect, RectangleF RotatedCoords, string DrawingMatrix) { #if (WPF) ColorBlend cb = aBrush.GradientStops; #else ColorBlend cb = null; try { if (aBrush.Blend == null) { cb = aBrush.InterpolationColors; //if it has interpolationcolors, blend must be null. } } catch (ArgumentException) //Awful way to tell if it has Interpolationcolors, but the framework does not give us a choice. { } if (cb == null) { cb = GetColorBlendWithoutInterpolationColors(aBrush.Blend, aBrush.LinearColors[0], aBrush.LinearColors[1]); } #endif int n = cb.Colors.Length - 1; if (cb.Colors[0].A != 255 || cb.Colors[n].A != 255) { ColorBlend TransparencyBlend = new ColorBlend(2); TransparencyBlend.Colors[0] = ColorUtil.FromArgb(cb.Colors[0].A, cb.Colors[0].A, cb.Colors[0].A); TransparencyBlend.Positions[0] = 0; TransparencyBlend.Colors[1] = ColorUtil.FromArgb(cb.Colors[n].A, cb.Colors[n].A, cb.Colors[n].A); TransparencyBlend.Positions[1] = 1; TPdfGradient SMask = Resources.GetGradient(TGradientType.Axial, TransparencyBlend, Rect, Rect.Location, RotatedCoords, DrawingMatrix); SelectTransparency(DataStream, 255, TPdfToken.CommandSetAlphaBrush, SMask.GetSMask(), PdfConv.ToRectangleXY(Rect, true)); } Resources.SelectGradient(DataStream, TGradientType.Axial, cb, Rect, Rect.Location, RotatedCoords, DrawingMatrix); }
internal void SelectGradient(TPdfStream DataStream, TGradientType aGradientType, ColorBlend aBlendColors, RectangleF aCoords, PointF aCenterPoint, RectangleF aRotatedCoords, string DrawingMatrix) { TPdfGradient SearchGradient = GetGradient(aGradientType, aBlendColors, aCoords, aCenterPoint, aRotatedCoords, DrawingMatrix); SearchGradient.Select(DataStream); }