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); } }
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)); }
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))))); }
/// <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)); }
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)); } }
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)); }
/// <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)); }
/// <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); }
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);*/ }
/// <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); }
/// <summary> /// Saves the storage layer to file. /// </summary> public void SaveStorage(StorageLayer layer, StreamWriter output) { SaveStorage(new[] { layer }, output); }
/// <summary> /// Compiles the storage layer. /// </summary> public static IGenerator ToCompiled(StorageLayer layer) { return(ToCompiled(ToRuntime(layer))); }
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)); }
public abstract Color GetColorForValue(StorageLayer parent, dynamic value);
/// <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); }
public override Color GetColorForValue(StorageLayer parent, dynamic value) { int a = (int)(255 * (value / (double)(this.MaxValue - this.MinValue))); return(Color.FromArgb(a, a, a)); }
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); }
public abstract Color GetColorForValue(StorageLayer parent, dynamic value);
/// <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); }
/// <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; }
/// <summary> /// Compiles the storage layer. /// </summary> public IGenerator ToCompiled(StorageLayer layer) { return ToCompiled(ToRuntime(layer)); }
/// <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; }
/// <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()); }
/// <summary> /// Saves the storage layer to file. /// </summary> public static void SaveStorage(StorageLayer layer, StreamWriter output) { SaveStorage(new StorageLayer[] { layer }, output); }