Exemple #1
0
        private WrapperItem DeepCopy()
        {
            WrapperItem other = (WrapperItem)this.MemberwiseClone();

            Color[] pixel_array = other.texture.GetPixels();
            other.int_channel = new float[pixel_array.Length];
            for (var n = 0; n < pixel_array.Length; n++)
            {
                //int[] array1 = { pixel_array [n].r,  pixel_array [n].g, pixel_array [n].b };
                //other.int_channel [n] = (int)array1.Average();
                other.int_channel [n] = pixel_array [n].r;
            }
            return(other);
        }
        List <WrapperItem> CreateWrappers(List <Texture2D> tex)
        {
            List <WrapperItem> Image_Wrappers = new List <WrapperItem>();

            for (var i = 0; i < tex.Count(); i++)
            {
                if (tex[i].GetType() == typeof(Texture2D))
                {
                    Texture2D   texture = tex[i] as Texture2D;
                    WrapperItem item    = new WrapperItem(texture, primary: true);
                    Image_Wrappers.Add(item);
                }
            }
            return(Image_Wrappers);
        }
Exemple #3
0
		private void PrivateColorShift(object[] tempStorage){
			slider.SetActive (true);
			new_texture = tempStorage [1].ToString ();
			Color color = (Color)tempStorage[0];
			var a = 0;
			for(var i = 0;i < wrappers.Count(); i++)
			{
				if(wrappers[i].texture.name == tempStorage [1].ToString ()) {a = i;}
			}
			curr_texture_image = wrappers [a];
			
			_camera.SetActive (true);
			_camera.GetComponent<Image> ().overrideSprite = wrappers [a].sprite;
			_camera.GetComponent<Image> ().color = Color.white;
			rend.material.mainTexture = UpdateBlend (color, curr_texture_image);
		}
Exemple #4
0
		Texture2D UpdateBlend (Color col, WrapperItem set)
		{
			var pixel_array = mat_texture.GetPixels ();
			if (previous_texture == new_texture) {
				for (var n = 0; n < pixel_count; n++) {
					temp_buffer_1 [0] [n] = temp_buffer_2 [0] [n] - set.intensity [n] * last_color.r * last_color.a + set.intensity [n] * col.r * col.a;
					temp_buffer_1 [1] [n] = temp_buffer_2 [1] [n] - set.intensity [n] * last_color.g * last_color.a + set.intensity [n] * col.g * col.a;
					temp_buffer_1 [2] [n] = temp_buffer_2 [2] [n] - set.intensity [n] * last_color.b * last_color.a + set.intensity [n] * col.b * col.a;
					
					pixel_array [n].r = temp_buffer_1 [0] [n];
					pixel_array [n].g = temp_buffer_1 [1] [n];
					pixel_array [n].b = temp_buffer_1 [2] [n];
					
					temp_buffer_2 [0] [n] = temp_buffer_1 [0] [n];
					temp_buffer_2 [1] [n] = temp_buffer_1 [1] [n];
					temp_buffer_2 [2] [n] = temp_buffer_1 [2] [n];
				}
				set.slider = slider_script.value;
				last_color = col;
			} else {
				slider_script.value = set.slider;
				for (var n = 0; n < pixel_count; n++) {
					temp_buffer_1 [0] [n] = (temp_buffer_1 [0] [n] + set.intensity [n] * col.r * col.a);
					temp_buffer_1 [1] [n] = (temp_buffer_1 [1] [n] + set.intensity [n] * col.g * col.a);
					temp_buffer_1 [2] [n] = (temp_buffer_1 [2] [n] + set.intensity [n] * col.b * col.a);
					
					pixel_array [n].r = temp_buffer_1 [0] [n];
					pixel_array [n].g = temp_buffer_1 [1] [n];
					pixel_array [n].b = temp_buffer_1 [2] [n];
					
					temp_buffer_2 [0][n] = temp_buffer_1 [0] [n];
					temp_buffer_2 [1][n] = temp_buffer_1 [1] [n];
					temp_buffer_2 [2][n] = temp_buffer_1 [2] [n];
				}
				set.slider = slider_script.value;
				last_color = Color.black;
			}
			
			previous_texture = new_texture;
			mat_texture.SetPixels(pixel_array);
			mat_texture.Apply(true);
			return mat_texture;
		}