//内積 public int InnerProduct(GSColor color1, GSColor color2) { int R1 = color1.R - R; int G1 = color1.G - G; int B1 = color1.B - B; int R2 = color2.R - R; int G2 = color2.G - G; int B2 = color2.B - B; return(R1 * R2 + G1 * G2 + B1 * B2); }
public static List <GSColor> Gradation(GSColor begin, GSColor end, int Length) { List <GSColor> colorList = new List <GSColor>(); if (Length == 0) { return(colorList); } double scaleR = (double)(end.R - begin.R) / Length; double scaleG = (double)(end.G - begin.G) / Length; double scaleB = (double)(end.B - begin.B) / Length; for (int i = 0; i < Length; i++) { colorList.Add(new GSColor((byte)(begin.R + scaleR * i), (byte)(begin.G + scaleG * i), (byte)(begin.B + scaleB * i))); } return(colorList); }
//影 public double Projection(GSColor end, GSColor color) { return(InnerProduct(end, color) / Distance(end)); }
public double Distance(GSColor color) { return(Math.Sqrt(Math.Pow(R - color.R, 2) + Math.Pow(G - color.G, 2) + Math.Pow(B - color.B, 2))); }
public Pixel(Position pos, GSColor color) { this.Pos = pos; this.Color = color; }