コード例 #1
0
        /// <summary>
        /// Takes a field of color data and renders it to a Texture2D.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public Texture2D Transform(NoiseField <Color> field)
        {
            Color[]   data    = field.Flatten();
            Texture2D texture = new Texture2D(Graphics, field.Width, field.Height);

            texture.SetData <Color>(data);
            return(texture);
        }
コード例 #2
0
        /// <summary>
        /// Performs a transformation on a float field to a Texture2D.  This will render as
        /// a grayscale image.
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public Texture2D Transform(NoiseField <float> field)
        {
            float[] data      = field.Flatten();
            Color[] colorData = new Color[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                colorData[i] = new Color(data[i], data[i], data[i]);
            }

            Texture2D texture = new Texture2D(Graphics, field.Width, field.Height);

            texture.SetData <Color>(colorData);
            return(texture);
        }