/// <summary> /// Constructs a {@code LinearGradientPaint}. /// </summary> /// <param name="start"> the gradient axis start {@code Point2D} in user space </param> /// <param name="end"> the gradient axis end {@code Point2D} in user space </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors corresponding to each fractional value </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} </param> /// <param name="colorSpace"> which color space to use for interpolation, /// either {@code SRGB} or {@code LINEAR_RGB} </param> /// <param name="gradientTransform"> transform to apply to the gradient /// </param> /// <exception cref="NullPointerException"> /// if one of the points is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null, /// or {@code colorSpace} is null, /// or {@code gradientTransform} is null </exception> /// <exception cref="IllegalArgumentException"> /// if start and end points are the same points, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ConstructorProperties({ "startPoint", "endPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" }) public LinearGradientPaint(java.awt.geom.Point2D start, java.awt.geom.Point2D end, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace, java.awt.geom.AffineTransform gradientTransform) public LinearGradientPaint(Point2D start, Point2D end, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace, AffineTransform gradientTransform) : base(fractions, colors, cycleMethod, colorSpace, gradientTransform) { // check input parameters if (start == null || end == null) { throw new NullPointerException("Start and end points must be" + "non-null"); } if (start.Equals(end)) { throw new IllegalArgumentException("Start point cannot equal" + "endpoint"); } // copy the points... this.Start = new Point2D.Double(start.X, start.Y); this.End = new Point2D.Double(end.X, end.Y); }
/// <summary> /// Constructs a {@code LinearGradientPaint} with a default {@code SRGB} /// color space. /// </summary> /// <param name="startX"> the X coordinate of the gradient axis start point /// in user space </param> /// <param name="startY"> the Y coordinate of the gradient axis start point /// in user space </param> /// <param name="endX"> the X coordinate of the gradient axis end point /// in user space </param> /// <param name="endY"> the Y coordinate of the gradient axis end point /// in user space </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors corresponding to each fractional value </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if start and end points are the same points, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, cycleMethod) { }
/// <summary> /// Constructs a {@code LinearGradientPaint} with a default {@code SRGB} /// color space. /// </summary> /// <param name="start"> the gradient axis start {@code Point2D} in user space </param> /// <param name="end"> the gradient axis end {@code Point2D} in user space </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors corresponding to each fractional value </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if one of the points is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if start and end points are the same points, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public LinearGradientPaint(Point2D start, Point2D end, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(start, end, fractions, colors, cycleMethod, ColorSpaceType.SRGB, new AffineTransform()) { }
/// <summary> /// Constructor for RadialGradientPaintContext. /// </summary> /// <param name="paint"> the {@code RadialGradientPaint} from which this context /// is created </param> /// <param name="cm"> the {@code ColorModel} that receives /// the {@code Paint} data (this is used only as a hint) </param> /// <param name="deviceBounds"> the device space bounding box of the /// graphics primitive being rendered </param> /// <param name="userBounds"> the user space bounding box of the /// graphics primitive being rendered </param> /// <param name="t"> the {@code AffineTransform} from user /// space into device space (gradientTransform should be /// concatenated with this) </param> /// <param name="hints"> the hints that the context object uses to choose /// between rendering alternatives </param> /// <param name="cx"> the center X coordinate in user space of the circle defining /// the gradient. The last color of the gradient is mapped to /// the perimeter of this circle. </param> /// <param name="cy"> the center Y coordinate in user space of the circle defining /// the gradient. The last color of the gradient is mapped to /// the perimeter of this circle. </param> /// <param name="r"> the radius of the circle defining the extents of the /// color gradient </param> /// <param name="fx"> the X coordinate in user space to which the first color /// is mapped </param> /// <param name="fy"> the Y coordinate in user space to which the first color /// is mapped </param> /// <param name="fractions"> the fractions specifying the gradient distribution </param> /// <param name="colors"> the gradient colors </param> /// <param name="cycleMethod"> either NO_CYCLE, REFLECT, or REPEAT </param> /// <param name="colorSpace"> which colorspace to use for interpolation, /// either SRGB or LINEAR_RGB </param> internal RadialGradientPaintContext(RadialGradientPaint paint, ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform t, RenderingHints hints, float cx, float cy, float r, float fx, float fy, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace) : base(paint, cm, deviceBounds, userBounds, t, hints, fractions, colors, cycleMethod, colorSpace) { // copy some parameters CenterX = cx; CenterY = cy; FocusX = fx; FocusY = fy; Radius = r; this.IsSimpleFocus = (FocusX == CenterX) && (FocusY == CenterY); this.IsNonCyclic = (cycleMethod == CycleMethod.NO_CYCLE); // for use in the quadractic equation RadiusSq = Radius * Radius; float dX = FocusX - CenterX; float dY = FocusY - CenterY; double distSq = (dX * dX) + (dY * dY); // test if distance from focus to center is greater than the radius if (distSq > RadiusSq * SCALEBACK) { // clamp focus to radius float scalefactor = (float)System.Math.Sqrt(RadiusSq * SCALEBACK / distSq); dX = dX * scalefactor; dY = dY * scalefactor; FocusX = CenterX + dX; FocusY = CenterY + dY; } // calculate the solution to be used in the case where X == focusX // in cyclicCircularGradientFillRaster() Trivial = (float)System.Math.Sqrt(RadiusSq - (dX * dX)); // constant parts of X, Y user space coordinates ConstA = A02 - CenterX; ConstB = A12 - CenterY; // constant second order delta for simple loop GDeltaDelta = 2 * (A00 * A00 + A10 * A10) / RadiusSq; }
/// <summary> /// Constructor for LinearGradientPaintContext. /// </summary> /// <param name="paint"> the {@code LinearGradientPaint} from which this context /// is created </param> /// <param name="cm"> {@code ColorModel} that receives /// the <code>Paint</code> data. This is used only as a hint. </param> /// <param name="deviceBounds"> the device space bounding box of the /// graphics primitive being rendered </param> /// <param name="userBounds"> the user space bounding box of the /// graphics primitive being rendered </param> /// <param name="t"> the {@code AffineTransform} from user /// space into device space (gradientTransform should be /// concatenated with this) </param> /// <param name="hints"> the hints that the context object uses to choose /// between rendering alternatives </param> /// <param name="start"> gradient start point, in user space </param> /// <param name="end"> gradient end point, in user space </param> /// <param name="fractions"> the fractions specifying the gradient distribution </param> /// <param name="colors"> the gradient colors </param> /// <param name="cycleMethod"> either NO_CYCLE, REFLECT, or REPEAT </param> /// <param name="colorSpace"> which colorspace to use for interpolation, /// either SRGB or LINEAR_RGB </param> internal LinearGradientPaintContext(LinearGradientPaint paint, ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform t, RenderingHints hints, Point2D start, Point2D end, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace) : base(paint, cm, deviceBounds, userBounds, t, hints, fractions, colors, cycleMethod, colorSpace) { // A given point in the raster should take on the same color as its // projection onto the gradient vector. // Thus, we want the projection of the current position vector // onto the gradient vector, then normalized with respect to the // length of the gradient vector, giving a value which can be mapped // into the range 0-1. // projection = // currentVector dot gradientVector / length(gradientVector) // normalized = projection / length(gradientVector) float startx = (float)start.X; float starty = (float)start.Y; float endx = (float)end.X; float endy = (float)end.Y; float dx = endx - startx; // change in x from start to end float dy = endy - starty; // change in y from start to end float dSq = dx * dx + dy * dy; // total distance squared // avoid repeated calculations by doing these divides once float constX = dx / dSq; float constY = dy / dSq; // incremental change along gradient for +x DgdX = A00 * constX + A10 * constY; // incremental change along gradient for +y DgdY = A01 * constX + A11 * constY; // constant, incorporates the translation components from the matrix Gc = (A02 - startx) * constX + (A12 - starty) * constY; }
/// <summary> /// Constructs a {@code RadialGradientPaint}. /// </summary> /// <param name="center"> the center point in user space of the circle defining the /// gradient. The last color of the gradient is mapped to /// the perimeter of this circle. </param> /// <param name="radius"> the radius of the circle defining the extents of the /// color gradient </param> /// <param name="focus"> the point in user space to which the first color is mapped </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} </param> /// <param name="colorSpace"> which color space to use for interpolation, /// either {@code SRGB} or {@code LINEAR_RGB} </param> /// <param name="gradientTransform"> transform to apply to the gradient /// </param> /// <exception cref="NullPointerException"> /// if one of the points is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null, /// or {@code colorSpace} is null, /// or {@code gradientTransform} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code radius} is non-positive, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ConstructorProperties({ "centerPoint", "radius", "focusPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" }) public RadialGradientPaint(java.awt.geom.Point2D center, float radius, java.awt.geom.Point2D focus, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace, java.awt.geom.AffineTransform gradientTransform) public RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace, AffineTransform gradientTransform) : base(fractions, colors, cycleMethod, colorSpace, gradientTransform) { // check input arguments if (center == null) { throw new NullPointerException("Center point must be non-null"); } if (focus == null) { throw new NullPointerException("Focus point must be non-null"); } if (radius <= 0) { throw new IllegalArgumentException("Radius must be greater " + "than zero"); } // copy parameters this.Center = new Point2D.Double(center.X, center.Y); this.Focus = new Point2D.Double(focus.X, focus.Y); this.Radius_Renamed = radius; }
/// <summary> /// Constructs a {@code RadialGradientPaint} with a default /// {@code SRGB} color space. /// The gradient circle of the {@code RadialGradientPaint} is defined /// by the given bounding box. /// <para> /// This constructor is a more convenient way to express the /// following (equivalent) code:<br> /// /// <pre> /// double gw = gradientBounds.getWidth(); /// double gh = gradientBounds.getHeight(); /// double cx = gradientBounds.getCenterX(); /// double cy = gradientBounds.getCenterY(); /// Point2D center = new Point2D.Double(cx, cy); /// /// AffineTransform gradientTransform = new AffineTransform(); /// gradientTransform.translate(cx, cy); /// gradientTransform.scale(gw / 2, gh / 2); /// gradientTransform.translate(-cx, -cy); /// /// RadialGradientPaint gp = /// new RadialGradientPaint(center, 1.0f, center, /// fractions, colors, /// cycleMethod, /// ColorSpaceType.SRGB, /// gradientTransform); /// </pre> /// /// </para> /// </summary> /// <param name="gradientBounds"> the bounding box, in user space, of the circle /// defining the outermost extent of the gradient </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if {@code gradientBounds} is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code gradientBounds} is empty, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public RadialGradientPaint(Rectangle2D gradientBounds, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(new Point2D.Double(gradientBounds.CenterX, gradientBounds.CenterY), 1.0f, new Point2D.Double(gradientBounds.CenterX, gradientBounds.CenterY), fractions, colors, cycleMethod, ColorSpaceType.SRGB, CreateGradientTransform(gradientBounds)) { // gradient center/focal point is the center of the bounding box, // radius is set to 1.0, and then we set a scale transform // to achieve an elliptical gradient defined by the bounding box if (gradientBounds.Empty) { throw new IllegalArgumentException("Gradient bounds must be " + "non-empty"); } }
/// <summary> /// Constructs a {@code RadialGradientPaint} with a default /// {@code SRGB} color space. /// </summary> /// <param name="cx"> the X coordinate in user space of the center point of the /// circle defining the gradient. The last color of the /// gradient is mapped to the perimeter of this circle. </param> /// <param name="cy"> the Y coordinate in user space of the center point of the /// circle defining the gradient. The last color of the /// gradient is mapped to the perimeter of this circle. </param> /// <param name="radius"> the radius of the circle defining the extents of the /// color gradient </param> /// <param name="fx"> the X coordinate of the point in user space to which the /// first color is mapped </param> /// <param name="fy"> the Y coordinate of the point in user space to which the /// first color is mapped </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code radius} is non-positive, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public RadialGradientPaint(float cx, float cy, float radius, float fx, float fy, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(new Point2D.Float(cx, cy), radius, new Point2D.Float(fx, fy), fractions, colors, cycleMethod) { }
/// <summary> /// Constructs a {@code RadialGradientPaint} with a default /// {@code SRGB} color space. /// </summary> /// <param name="center"> the center point, in user space, of the circle defining /// the gradient. The last color of the gradient is mapped /// to the perimeter of this circle. </param> /// <param name="radius"> the radius of the circle defining the extents of the color /// gradient </param> /// <param name="focus"> the point in user space to which the first color is mapped </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if one of the points is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code radius} is non-positive, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(center, radius, focus, fractions, colors, cycleMethod, ColorSpaceType.SRGB, new AffineTransform()) { }
/// <summary> /// Constructs a {@code RadialGradientPaint} with a default /// {@code SRGB} color space, using the center as the focus point. /// </summary> /// <param name="center"> the center point, in user space, of the circle defining /// the gradient </param> /// <param name="radius"> the radius of the circle defining the extents of the /// color gradient </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if {@code center} point is null, /// or {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code radius} is non-positive, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public RadialGradientPaint(Point2D center, float radius, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(center, radius, center, fractions, colors, cycleMethod) { }
/// <summary> /// Constructs a {@code RadialGradientPaint} with a default /// {@code SRGB} color space, using the center as the focus point. /// </summary> /// <param name="cx"> the X coordinate in user space of the center point of the /// circle defining the gradient. The last color of the /// gradient is mapped to the perimeter of this circle. </param> /// <param name="cy"> the Y coordinate in user space of the center point of the /// circle defining the gradient. The last color of the /// gradient is mapped to the perimeter of this circle. </param> /// <param name="radius"> the radius of the circle defining the extents of the /// color gradient </param> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors to use in the gradient. The first color /// is used at the focus point, the last color around the /// perimeter of the circle. </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} /// </param> /// <exception cref="NullPointerException"> /// if {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code cycleMethod} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code radius} is non-positive, /// or {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> public RadialGradientPaint(float cx, float cy, float radius, float[] fractions, Color[] colors, CycleMethod cycleMethod) : this(cx, cy, radius, cx, cy, fractions, colors, cycleMethod) { }
/// <summary> /// Package-private constructor. /// </summary> /// <param name="fractions"> numbers ranging from 0.0 to 1.0 specifying the /// distribution of colors along the gradient </param> /// <param name="colors"> array of colors corresponding to each fractional value </param> /// <param name="cycleMethod"> either {@code NO_CYCLE}, {@code REFLECT}, /// or {@code REPEAT} </param> /// <param name="colorSpace"> which color space to use for interpolation, /// either {@code SRGB} or {@code LINEAR_RGB} </param> /// <param name="gradientTransform"> transform to apply to the gradient /// </param> /// <exception cref="NullPointerException"> /// if {@code fractions} array is null, /// or {@code colors} array is null, /// or {@code gradientTransform} is null, /// or {@code cycleMethod} is null, /// or {@code colorSpace} is null </exception> /// <exception cref="IllegalArgumentException"> /// if {@code fractions.length != colors.length}, /// or {@code colors} is less than 2 in size, /// or a {@code fractions} value is less than 0.0 or greater than 1.0, /// or the {@code fractions} are not provided in strictly increasing order </exception> internal MultipleGradientPaint(float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace, AffineTransform gradientTransform) { if (fractions == null) { throw new NullPointerException("Fractions array cannot be null"); } if (colors == null) { throw new NullPointerException("Colors array cannot be null"); } if (cycleMethod == null) { throw new NullPointerException("Cycle method cannot be null"); } if (colorSpace == null) { throw new NullPointerException("Color space cannot be null"); } if (gradientTransform == null) { throw new NullPointerException("Gradient transform cannot be " + "null"); } if (fractions.Length != colors.Length) { throw new IllegalArgumentException("Colors and fractions must " + "have equal size"); } if (colors.Length < 2) { throw new IllegalArgumentException("User must specify at least " + "2 colors"); } // check that values are in the proper range and progress // in increasing order from 0 to 1 float previousFraction = -1.0f; foreach (float currentFraction in fractions) { if (currentFraction < 0f || currentFraction > 1f) { throw new IllegalArgumentException("Fraction values must " + "be in the range 0 to 1: " + currentFraction); } if (currentFraction <= previousFraction) { throw new IllegalArgumentException("Keyframe fractions " + "must be increasing: " + currentFraction); } previousFraction = currentFraction; } // We have to deal with the cases where the first gradient stop is not // equal to 0 and/or the last gradient stop is not equal to 1. // In both cases, create a new point and replicate the previous // extreme point's color. bool fixFirst = false; bool fixLast = false; int len = fractions.Length; int off = 0; if (fractions[0] != 0f) { // first stop is not equal to zero, fix this condition fixFirst = true; len++; off++; } if (fractions[fractions.Length - 1] != 1f) { // last stop is not equal to one, fix this condition fixLast = true; len++; } this.Fractions_Renamed = new float[len]; System.Array.Copy(fractions, 0, this.Fractions_Renamed, off, fractions.Length); this.Colors_Renamed = new Color[len]; System.Array.Copy(colors, 0, this.Colors_Renamed, off, colors.Length); if (fixFirst) { this.Fractions_Renamed[0] = 0f; this.Colors_Renamed[0] = colors[0]; } if (fixLast) { this.Fractions_Renamed[len - 1] = 1f; this.Colors_Renamed[len - 1] = colors[colors.Length - 1]; } // copy some flags this.ColorSpace_Renamed = colorSpace; this.CycleMethod_Renamed = cycleMethod; // copy the gradient transform this.GradientTransform = new AffineTransform(gradientTransform); // determine transparency bool opaque = true; for (int i = 0; i < colors.Length; i++) { opaque = opaque && (colors[i].Alpha == 0xff); } this.Transparency_Renamed = opaque ? Transparency_Fields.OPAQUE : Transparency_Fields.TRANSLUCENT; }
/// <summary> /// Constructor for MultipleGradientPaintContext superclass. /// </summary> protected internal MultipleGradientPaintContext(MultipleGradientPaint mgp, ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform t, RenderingHints hints, float[] fractions, Color[] colors, CycleMethod cycleMethod, ColorSpaceType colorSpace) { if (deviceBounds == null) { throw new NullPointerException("Device bounds cannot be null"); } if (userBounds == null) { throw new NullPointerException("User bounds cannot be null"); } if (t == null) { throw new NullPointerException("Transform cannot be null"); } if (hints == null) { throw new NullPointerException("RenderingHints cannot be null"); } // The inverse transform is needed to go from device to user space. // Get all the components of the inverse transform matrix. AffineTransform tInv; try { // the following assumes that the caller has copied the incoming // transform and is not concerned about it being modified t.Invert(); tInv = t; } catch (NoninvertibleTransformException) { // just use identity transform in this case; better to show // (incorrect) results than to throw an exception and/or no-op tInv = new AffineTransform(); } double[] m = new double[6]; tInv.GetMatrix(m); A00 = (float)m[0]; A10 = (float)m[1]; A01 = (float)m[2]; A11 = (float)m[3]; A02 = (float)m[4]; A12 = (float)m[5]; // copy some flags this.CycleMethod = cycleMethod; this.ColorSpace = colorSpace; // we can avoid copying this array since we do not modify its values this.Fractions = fractions; // note that only one of these values can ever be non-null (we either // store the fast gradient array or the slow one, but never both // at the same time) int[] gradient = (mgp.Gradient != null) ? mgp.Gradient.get() : null; int[][] gradients = (mgp.Gradients != null) ? mgp.Gradients.get() : null; if (gradient == null && gradients == null) { // we need to (re)create the appropriate values CalculateLookupData(colors); // now cache the calculated values in the // MultipleGradientPaint instance for future use mgp.Model = this.Model; mgp.NormalizedIntervals = this.NormalizedIntervals; mgp.IsSimpleLookup = this.IsSimpleLookup; if (IsSimpleLookup) { // only cache the fast array mgp.FastGradientArraySize = this.FastGradientArraySize; mgp.Gradient = new SoftReference <int[]>(this.Gradient); } else { // only cache the slow array mgp.Gradients = new SoftReference <int[][]>(this.Gradients); } } else { // use the values cached in the MultipleGradientPaint instance this.Model = mgp.Model; this.NormalizedIntervals = mgp.NormalizedIntervals; this.IsSimpleLookup = mgp.IsSimpleLookup; this.Gradient = gradient; this.FastGradientArraySize = mgp.FastGradientArraySize; this.Gradients = gradients; } }
public EntAudioSourceAction(List<AudioClip> clips, CycleMethod cycle) : this(clips) { Cycle = cycle; }