/*** Specifies the length of the gradient. * @paramC0 the starting color. * @paramC1 End color. * @paramLen's limited gradient length, to ensure that each color is different, finds the maximum length based on the color. * @returnthe length is all the colors of the parameter len+1. */ Public StaticArraylist<integer> Gradient (intC0,intC1,DoubleLen) { int[] fc = {(C0 & 0xff0000) >>, (C0 & 0xff00) >> 8, C0 & 0xFF }; int[] TC = {(C1 & 0xff0000) >>, (C1 & 0xff00) >> 8, C1 & 0xFF }; Len= Math.min (len, Math.max (Math.max (Math.Abs (fc[0]-tc[0), Math.Abs (Fc[1]-tc[1]), Math.Abs (fc[2)-tc[2]))); Double[] s = {(tc[0]-fc[0])/Len, (Tc[1]-fc[1])/Len, (Tc[2]-fc[2])/Len,}; ArrayList<Integer> r =NewArraylist<integer>(); for(inti = 0; i < Len; i++) {R.add (fc[0] + (int) (I * s[0]) << 16 | FC[1] + (int) (I * s[1]) << 8 | FC[2] + (int) (I * s[2])); } r.add (C1); returnR; }
C # is so lazy that it's no wonder that C # developers have a low average level. Occasionally use C # happiness multiplier!
Java implementation of the gradient algorithm