public void ChangeSliderColor(int index) { ImagePack imagePack = this.imgPack[index]; if (imagePack == null || !imagePack.isTex) { return; } Vector2 size = imagePack.size; int x = (int)size.x; int y = (int)size.y; Color[] colors = new Color[y * x]; float[] val = new float[3] { ((Color) ref this._color).get_Item(0), ((Color) ref this._color).get_Item(1), ((Color) ref this._color).get_Item(2) }; Action <int> action; if (!this.isHSV) { action = (Action <int>)(i => colors[i] = new Color(val[0], val[1], val[2])); } else { if (index == 0) { val[1] = 1f; val[2] = 1f; } action = (Action <int>)(i => colors[i] = Color.HSVToRGB(val[0], val[1], val[2])); } if (y > x) { for (int index1 = 0; index1 < y; ++index1) { for (int index2 = 0; index2 < x; ++index2) { val[index] = Mathf.InverseLerp(0.0f, (float)size.y, (float)index1); action(index1 * x + index2); } } } else { for (int index1 = 0; index1 < y; ++index1) { for (int index2 = 0; index2 < x; ++index2) { val[index] = Mathf.InverseLerp(0.0f, (float)size.x, (float)index2); action(index1 * x + index2); } } } imagePack.SetPixels(colors); }
public void ChangeSliderColor() { ImagePack imagePack = this.imgPack[1]; if (imagePack == null || !imagePack.isTex) { return; } int index1 = (int)this.mode % 3; Vector2 size = imagePack.size; int x = (int)size.x; int y = (int)size.y; Color[] colors = new Color[y * x]; switch (this.mode) { case PickerRect.Mode.Hue: case PickerRect.Mode.Saturation: case PickerRect.Mode.Value: float[] rateHsv = this.RateHSV; if (this.mode == PickerRect.Mode.Hue) { rateHsv[1] = 1f; rateHsv[2] = 1f; } for (int index2 = 0; index2 < y; ++index2) { for (int index3 = 0; index3 < x; ++index3) { rateHsv[index1] = Mathf.InverseLerp(0.0f, (float)size.y, (float)index2); colors[index2 * x + index3] = HsvColor.ToRgb(rateHsv[0] * 360f, rateHsv[1], rateHsv[2]); } } break; case PickerRect.Mode.Red: case PickerRect.Mode.Green: case PickerRect.Mode.Blue: float[] rgb = this.RGB; for (int index2 = 0; index2 < y; ++index2) { for (int index3 = 0; index3 < x; ++index3) { rgb[index1] = Mathf.InverseLerp(0.0f, (float)size.y, (float)index2); colors[index2 * x + index3] = new Color(rgb[0], rgb[1], rgb[2]); } } break; } imagePack.SetPixels(colors); }
public void ChangeRectColor() { ImagePack imagePack = this.imgPack[0]; if (imagePack == null || !imagePack.isTex) { return; } int index1 = (int)this.mode % 3; Vector2 size = imagePack.size; int x = (int)size.x; int y = (int)size.y; Color[] colors = new Color[y * x]; switch (this.mode) { case PickerRect.Mode.Hue: case PickerRect.Mode.Saturation: case PickerRect.Mode.Value: float[] rateHsv = this.RateHSV; int[,] numArray1 = new int[3, 3] { { 1, 2, 0 }, { 0, 2, 1 }, { 0, 1, 2 } }; for (int index2 = 0; index2 < y; ++index2) { for (int index3 = 0; index3 < x; ++index3) { rateHsv[numArray1[index1, 0]] = Mathf.InverseLerp(0.0f, (float)size.x, (float)index3); rateHsv[numArray1[index1, 1]] = Mathf.InverseLerp(0.0f, (float)size.y, (float)index2); colors[index2 * x + index3] = HsvColor.ToRgb(360f * rateHsv[0], rateHsv[1], rateHsv[2]); } } break; case PickerRect.Mode.Red: case PickerRect.Mode.Green: case PickerRect.Mode.Blue: float[] rgb = this.RGB; int[,] numArray2 = new int[3, 3] { { 2, 1, 0 }, { 2, 0, 1 }, { 0, 1, 2 } }; for (int index2 = 0; index2 < y; ++index2) { for (int index3 = 0; index3 < x; ++index3) { rgb[numArray2[index1, 0]] = Mathf.InverseLerp(0.0f, (float)size.x, (float)index3); rgb[numArray2[index1, 1]] = Mathf.InverseLerp(0.0f, (float)size.y, (float)index2); colors[index2 * x + index3] = new Color(rgb[0], rgb[1], rgb[2]); } } break; } imagePack.SetPixels(colors); }