/// <summary> /// Creates gradient with a given number of colours and gradient type. /// </summary> /// <param name="colours"></param> /// <param name="type"></param> /// <returns></returns> public static GradientFill CreateGradient([MinUInt(2)] uint colours) { GradientFill fill = null; if (colours <= 4) { fill = new Gradient4Fill(); } // We create and initialize it. if (fill != null) { fill.colours = new Colour[colours]; fill.positions = new float[colours - 2]; return(fill); } throw new NotImplementedException("This kind of gradient not yet supported."); }
public override bool Equals(IFill other) { if (other is Gradient4Fill) { Gradient4Fill fill = (Gradient4Fill)other; if (fill.texcoordMixing != texcoordMixing) { return(false); } if (this.colours.Length != fill.colours.Length) { return(false); } // We compare all colours. for (int i = 0; i < colours.Length; i++) { if (colours[i] != fill.colours[i]) { return(false); } } for (int j = 0; j < positions.Length; j++) { if (positions[j] != fill.positions[j]) { return(false); } } return(true); } return(false); }