public override Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     if (this.ColorSet == ColorScheme.Perlin)
     {
         if (value == this.LowerValue)
         {
             return(Color.Black);
         }
         else
         {
             return(Color.White);
         }
     }
     else if (this.ColorSet == ColorScheme.Land)
     {
         if (value == this.LowerValue)
         {
             return(Color.Blue);
         }
         else
         {
             return(Color.Green);
         }
     }
     else
     {
         return(Color.Gray);
     }
 }
Exemple #2
0
        public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            switch ((int)value)
            {
            default:
                return(System.Drawing.Color.FromArgb(150, 150, 150));

            case 0:
                return(System.Drawing.Color.FromArgb(0, 0, 0));

            case 1:
                return(System.Drawing.Color.FromArgb(255, 0, 0));

            case 2:
                return(System.Drawing.Color.FromArgb(0, 255, 0));

            case 3:
                return(System.Drawing.Color.FromArgb(255, 255, 0));

            case 4:
                return(System.Drawing.Color.FromArgb(0, 0, 255));

            case 5:
                return(System.Drawing.Color.FromArgb(255, 0, 255));

            case 6:
                return(System.Drawing.Color.FromArgb(0, 255, 255));

            case 7:
                return(System.Drawing.Color.FromArgb(255, 255, 255));
            }
        }
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            int a;

            double divvalue = (double)this.EstimateMax;

            if (divvalue > 255)
            {
                divvalue = 255;
            }
            else if (divvalue < 1)
            {
                divvalue = 1;
            }

            a = (int)(value * ((double)255 / divvalue));

            if (a > 255)
            {
                a = 255;
            }
            if (a < 0)
            {
                a = 0;
            }

            return(Color.FromArgb(a, a, a));
        }
Exemple #4
0
 public override Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     return(Color.FromArgb(
                (int)(255 * ((value - this.MinValue) / (float)(this.MaxValue - this.MinValue))),
                (int)(255 * ((value - this.MinValue) / (float)(this.MaxValue - this.MinValue))),
                (int)(255 * ((value - this.MinValue) / (float)(this.MaxValue - this.MinValue)))));
 }
Exemple #5
0
 /// <summary>
 /// Delegates the color logic to the primary input of this algorithm.
 /// </summary>
 /// <param name="parent">The primary input.</param>
 /// <param name="value">The value to determine.</param>
 /// <returns>The color determined by the parent.</returns>
 public Color DelegateColorForValueToParent(StorageLayer parent, dynamic value, int index = 0)
 {
     if (parent != null)
     {
         return(parent.Algorithm.GetColorForValue(parent.Inputs.Length >= (index + 1) ? parent.Inputs[index] : null, value));
     }
     return(Color.Gray);
 }
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            if (value == null)
            {
                return(Color.Gray);
            }

            return(value.BrushColor);
        }
        public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            if (value == 0)
            {
                return(Color.Black);
            }

            int a;

            double divvalue = (double)this.EstimateMax;

            if (divvalue > 255)
            {
                divvalue = 255;
            }
            else if (divvalue < 1)
            {
                divvalue = 1;
            }

            a = (int)(value * ((double)255 / divvalue));

            if (a < 0)
            {
                if (this.InverseColours)
                {
                    if (a < -255)
                    {
                        return(Color.FromArgb(0, 255, 0));
                    }
                    return(Color.FromArgb(0, -a, 0));
                }

                if (a < -255)
                {
                    return(Color.FromArgb(0, 0, 255));
                }
                return(Color.FromArgb(0, 0, -a));
            }

            if (a > 255)
            {
                a = 255;
            }

            if (a == 0)
            {
                return(Color.Black);
            }
            if (this.InverseColours)
            {
                return(Color.FromArgb(0, 0, a));
            }
            return(Color.FromArgb(0, a, 0));
        }
        public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            int a = value;

            if (a > 255)
            {
                a = 255;
            }

            return(Color.FromArgb(a, a, a));
        }
Exemple #9
0
 public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     if (value <= 0)
     {
         return(System.Drawing.Color.FromArgb(0, 0, 255));
     }
     else
     {
         return(System.Drawing.Color.FromArgb(Math.Max(Math.Min(value / 256, 255), 0), Math.Max(Math.Min(value % 256, 255), 0), 0));
     }
 }
Exemple #10
0
 public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     if (value == 0)
     {
         return(System.Drawing.Color.FromArgb(1, 0, 0, 0));
     }
     else
     {
         return(System.Drawing.Color.FromArgb(255, 0, 0));
     }
 }
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            var color = this.DelegateColorForValueToParent(parent, value);
            int b     = color.B;

            if (b > 0)
            {
                b = color.B - (byte)((255 - (int)color.B) * (this.Divisor - 1));
            }
            b = Math.Min(b, 255);
            b = Math.Max(0, b);
            return(Color.FromArgb(color.A, color.R, color.G, b));
        }
Exemple #12
0
 /// <summary>
 /// Adds all the layers recursively to a list.
 /// </summary>
 public static void AddRecursiveStorage(List <StorageLayer> allLayers, StorageLayer layer)
 {
     if (!allLayers.Contains(layer))
     {
         allLayers.Add(layer);
     }
     if (layer != null && layer.Inputs != null)
     {
         foreach (var input in layer.Inputs)
         {
             AddRecursiveStorage(allLayers, input);
         }
     }
 }
        public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            if (value == 0)
            {
                return(Color.FromArgb(0, 0, 255));
            }

            int a = value * 20;

            if (a > 255)
            {
                a = 255;
            }

            //int a = Math.Min(Math.Max(value, 0), 255);
            return(Color.FromArgb(a, a, a));
        }
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            if (this.Initial)
            {
                if (value == -1)
                {
                    return(Color.Orange);
                }
                if (value == 0)
                {
                    return(Color.Yellow);
                }
                if (value == 1)
                {
                    return(Color.Green);
                }
                return(Color.Red);
            }

            if (this.MaxTerrainBinary < 0)
            {
                this.MaxTerrainBinary = 0;
            }
            var maxValue = 1 << this.MaxTerrainBinary;
            var minValue = -(1 << this.MaxTerrainBinary);
            int a;

            if (value < 0)
            {
                a = 215 - (int)(value / (double)minValue * 180);
            }
            else
            {
                a = 64 + (int)(value / (double)maxValue * 127);
            }
            if (a < 0 || a > 255)
            {
                return(Color.Red);
            }

            return(Color.FromArgb(0, value < 0 ? 0 : a, value < 0 ? a : 0));
        }
Exemple #15
0
        /// <summary>
        /// Converts the loaded storage layer into a runtime layer.
        /// </summary>
        public static RuntimeLayer ToRuntime(StorageLayer layer)
        {
            // Handle null conversion.
            if (layer == null)
            {
                return(null);
            }

            // Convert runtime layer.
            var runtime = new RuntimeLayer(layer.Algorithm);

            if (layer.Inputs != null)
            {
                for (var i = 0; i < layer.Inputs.Length; i++)
                {
                    runtime.SetInput(i, StorageAccess.ToRuntime(layer.Inputs[i]));
                }
            }
            return(runtime);
        }
Exemple #16
0
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            return(this.DelegateColorForValueToParent(parent, value));

            /*
             * int a;
             *
             * double divvalue = (double)this.EstimateMax;
             *
             * if (divvalue > 255)
             *  divvalue = 255;
             * else if (divvalue < 1)
             *  divvalue = 1;
             *
             * a = (int)(value * ((double)255 / divvalue));
             *
             * if (a > 255)
             *  a = 255;
             *
             * return Color.FromArgb(a, a, a);*/
        }
Exemple #17
0
        /// <summary>
        /// Converts the runtime layer representation into
        /// a storage layer so that it can be saved.
        /// </summary>
        public static StorageLayer FromRuntime(RuntimeLayer layer)
        {
            // Handle null conversion.
            if (layer == null)
            {
                return(null);
            }

            // Create storage.
            var storage = new StorageLayer
            {
                Algorithm = layer.Algorithm
            };

            // Convert inputs.
            for (int i = 0; i < layer.GetInputs().Length; i++)
            {
                storage.Inputs[i] = StorageAccess.FromRuntime(layer.GetInputs()[i]);
            }

            // Return storage.
            return(storage);
        }
Exemple #18
0
 /// <summary>
 /// Saves the storage layer to file.
 /// </summary>
 public void SaveStorage(StorageLayer layer, StreamWriter output)
 {
     SaveStorage(new[] { layer }, output);
 }
Exemple #19
0
 /// <summary>
 /// Compiles the storage layer.
 /// </summary>
 public static IGenerator ToCompiled(StorageLayer layer)
 {
     return(ToCompiled(ToRuntime(layer)));
 }
Exemple #20
0
 public void OnGeneratePerformanceResultsResponse(
     StorageLayer layer,
     Bitmap resultsBitmap,
     Bitmap compiledBitmap)
 {
     var element = this.c_FlowInterfaceControl.Elements
         .Where(x => x is AlgorithmFlowElement)
         .Cast<AlgorithmFlowElement>()
         .FirstOrDefault(x => x.Layer == layer);
     if (element == null)
         return;
     element.UpdateBitmaps(null, compiledBitmap, resultsBitmap);
     this.m_PerformanceResultsLeftToCalculate--;
     this.UpdateStatusArea();
 }
 public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     return(this.DelegateColorForValueToParent(parent, value));
 }
Exemple #22
0
 public abstract Color GetColorForValue(StorageLayer parent, dynamic value);
Exemple #23
0
 /// <summary>
 /// Delegates the color logic to one of the parents of this algorithm.
 /// </summary>
 /// <param name="layer">The storage layer holding this algorithm.</param>
 /// <param name="value">The value to determine.</param>
 /// <param name="index">The index of the parent to delegate to.</param>
 /// <returns>The color determined by the parent.</returns>
 public Color DelegateColorForValueToParent(StorageLayer layer, dynamic value, int index = 0)
 {
     if (layer.Inputs[index] == null)
         return Color.Gray;
     return layer.Inputs[index].Algorithm.GetColorForValue(layer.Inputs[index], value);
 }
Exemple #24
0
        public override Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            int a = (int)(255 * (value / (double)(this.MaxValue - this.MinValue)));

            return(Color.FromArgb(a, a, a));
        }
Exemple #25
0
 public void OnGenerateRuntimeBitmapStart(StorageLayer layer, Bitmap bitmap)
 {
     var element = this.c_FlowInterfaceControl.Elements
         .Where(x => x is AlgorithmFlowElement)
         .Cast<AlgorithmFlowElement>()
         .FirstOrDefault(x => x.Layer == layer);
     if (element == null)
         return;
     element.UpdateBitmaps(null, null, bitmap);
 }
Exemple #26
0
 public abstract Color GetColorForValue(StorageLayer parent, dynamic value);
Exemple #27
0
 /// <summary>
 /// Adds all the layers recursively to a list.
 /// </summary>
 public void AddRecursiveStorage(List<StorageLayer> allLayers, StorageLayer layer)
 {
     if (!allLayers.Contains(layer))
         allLayers.Add(layer);
     if (layer != null && layer.Inputs != null)
         foreach (var input in layer.Inputs)
             AddRecursiveStorage(allLayers, input);
 }
 public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
 {
     return(this.Color);
 }
        public override System.Drawing.Color GetColorForValue(StorageLayer parent, dynamic value)
        {
            if (value == Int32.MaxValue)
            {
                return(Color.Transparent);
            }

            if (ColorSet == ColorScheme.Land)
            {
                return(this.DelegateColorForValueToParent(parent, value));
            }

            int a;

            double divvalue = (double)this.EstimateMax;

            if (divvalue > 255)
            {
                divvalue = 255;
            }
            else if (divvalue < 1)
            {
                divvalue = 1;
            }

            a = (int)(value * ((double)255 / divvalue));

            if (a < 0)
            {
                if (a < -255)
                {
                    if (ColorSet == ColorScheme.Land)
                    {
                        return(Color.FromArgb(0, 0, 255));
                    }
                    else if (ColorSet == ColorScheme.Perlin)
                    {
                        return(Color.FromArgb(255, 255, 255));
                    }

                    return(Color.Red);
                }

                if (ColorSet == ColorScheme.Land)
                {
                    return(Color.FromArgb(0, 0, 255 - a));
                }
                else if (ColorSet == ColorScheme.Perlin)
                {
                    return(Color.FromArgb(-a, -a, -a));
                }
            }

            if (a > 255)
            {
                a = 255;
            }

            if (a == 0)
            {
                return(Color.Black);
            }

            if (ColorSet == ColorScheme.Land)
            {
                return(Color.FromArgb(0, a, 0));
            }
            else if (ColorSet == ColorScheme.Perlin)
            {
                return(Color.FromArgb(a, a, a));
            }

            return(Color.Red);
        }
Exemple #30
0
        /// <summary>
        /// Converts the loaded storage layer into a runtime layer.
        /// </summary>
        public RuntimeLayer ToRuntime(StorageLayer layer)
        {
            // Handle null conversion.
            if (layer == null)
                return null;

            // Convert runtime layer.
            var runtime = new RuntimeLayer(
                this.m_Pool,
                this.m_ArrayPool,
                layer.Algorithm,
                this.m_AssetManagerProvider);
            if (layer.Inputs != null)
                for (var i = 0; i < layer.Inputs.Length; i++)
                    runtime.SetInput(i, ToRuntime(layer.Inputs[i]));
            return runtime;
        }
Exemple #31
0
 /// <summary>
 /// Compiles the storage layer.
 /// </summary>
 public IGenerator ToCompiled(StorageLayer layer)
 {
     return ToCompiled(ToRuntime(layer));
 }
Exemple #32
0
        /// <summary>
        /// Converts the runtime layer representation into
        /// a storage layer so that it can be saved.
        /// </summary>
        public StorageLayer FromRuntime(RuntimeLayer layer)
        {
            // Handle null conversion.
            if (layer == null)
                return null;

            // Create storage.
            var storage = new StorageLayer
            {
                Algorithm = layer.Algorithm
            };

            // Convert inputs.
            for (var i = 0; i < layer.GetInputs().Length; i++)
                storage.Inputs[i] = FromRuntime(layer.GetInputs()[i]);

            // Return storage.
            return storage;
        }
Exemple #33
0
        /// <summary>
        /// Saves the storage layers to file.
        /// </summary>
        public void SaveStorage(StorageLayer[] layers, StreamWriter output)
        {
            // Find all possible layers that need to saved.
            var allLayers = layers.ToList();
            foreach (var layer in layers)
                AddRecursiveStorage(allLayers, layer);

            // Save all.
            var x = new DataContractSerializer(
                typeof(StorageLayer[]),
                SerializableTypes,
                int.MaxValue,
                false,
                true,
                null);
            x.WriteObject(output.BaseStream, allLayers.ToArray());
        }
Exemple #34
0
 /// <summary>
 /// Saves the storage layer to file.
 /// </summary>
 public static void SaveStorage(StorageLayer layer, StreamWriter output)
 {
     SaveStorage(new StorageLayer[] { layer }, output);
 }