Example #1
0
        public static Color[] ToColorMap(float[,] values, IColorConnection colorSampler = null, OutputSocket colorRequestSocket = null)
        {
            int width  = values.GetLength(0);
            int height = values.GetLength(1);

            Color[] colorMap = new Color[width * height];
            Request request  = new Request();

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color c;
                    if (colorSampler == null)
                    {
                        c = GetGreyscaleColor(values[x, y]);
                    }
                    else
                    {
                        request.X = x;
                        request.Y = (values[x, y] + 1f) / 2f;
                        request.Z = y;
                        c         = colorSampler.GetColor(colorRequestSocket, request);
                    }
                    colorMap[y * width + x] = c;
                }
            }
            return(colorMap);
        }
Example #2
0
 public void Request(int startX, int startZ, int width, int height, List <UnityEngine.Vector3> positions)
 {
     _startX       = startX;
     _startZ       = startZ;
     _positions    = positions;
     _samplerColor = new Vector3DisplayColorSampler();
     Width         = width;
     Height        = height;
 }
Example #3
0
 public void Request(int startX, int startZ, int width, int height,
                     INumberConnection numberSampler, OutputSocket numberSamplerRequestSocket,
                     IColorConnection colorSampler = null, OutputSocket colorSamplerOutSocket = null)
 {
     _startX        = startX;
     _startZ        = startZ;
     _numberSampler = numberSampler;
     _numberSamplerRequestSocket = numberSamplerRequestSocket;
     _samplerColor = colorSampler;
     _colorSamplerRequestSocket = colorSamplerOutSocket;
     _values = new float[width, height];
     Width   = width;
     Height  = height;
 }
        public static UnityEngine.Color GetInputColor(InputSocket socket, Request request)
        {
            if (!socket.IsConnected())
            {
                return(UnityEngine.Color.magenta);
            }
            IColorConnection sampler = socket.GetConnectedSocket().Parent as IColorConnection;

            if (sampler == null)
            {
                return(UnityEngine.Color.magenta);
            }
            return(sampler.GetColor(socket.GetConnectedSocket(), request));
        }