protected Layer(Layer parent) { this.m_Parents = new Layer[] { parent }; if (parent != null) { this.m_Seed = parent.m_Seed; this.TransformSeed(); } }
protected Layer(Layer[] parents) { if (parents == null) throw new ArgumentNullException("parents"); if (parents.Length < 1) throw new ArgumentOutOfRangeException("parents"); this.m_Parents = parents; if (parents[0] != null) { this.m_Seed = parents[0].m_Seed; this.TransformSeed(); } }
public static ImageTask RegenerateImageForLayerSync(FlowInterfaceControl fic, Layer l, int width, int height, Action act) { ImageTask it = new ImageTask(); ProgressCallback callback = (progress, bitmap) => { #if FALSE it.Progress = progress; #endif if (bitmap != null) { it.HasResult = true; it.Result = bitmap; } act(); }; RegenerateImageForLayer(fic, l, width, height, callback); return it; }
private static Bitmap RegenerateImageForLayer(FlowInterfaceControl fic, Layer l, int width, int height, ProgressCallback callback) { Bitmap b = new Bitmap(width, height); Graphics g = Graphics.FromImage(b); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; Dictionary<int, Brush> brushes = l.GetLayerColors(); int[] data = l.GenerateData(LayerFlowImageGeneration.X, LayerFlowImageGeneration.Y, width, height); for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) { while (true) { try { if (brushes != null && brushes.ContainsKey(data[x + y * width])) g.FillRectangle( brushes[data[x + y * (width)]], new Rectangle(x, y, 1, 1) ); else g.FillRectangle( m_UnknownAssociation, new Rectangle(x, y, 1, 1) ); #if FALSE callback((int)((x + y * width) / (double)(width * height) * 100.0), null); #else callback(0, null); #endif break; } catch (InvalidOperationException) { // Graphics can be in use elsewhere, but we don't care; just try again. } } } callback(100, b); return b; }
public LayerFlowConnector(LayerFlowElement owner, string name, bool isInput, Layer layer) : base(owner, name, isInput) { this.m_Layer = layer; this.m_LayerOwner = owner; }
public LayerZoom(Layer parent) : base(parent) { this.Mode = ZoomType.Smooth; this.Iterations = 1; }
public void SetParent(int idx, Layer parent) { if (this.m_Parents.Length <= idx) { // Resize up. Layer[] newParents = new Layer[idx + 1]; for (int i = 0; i < this.m_Parents.Length; i++) newParents[i] = this.m_Parents[i]; newParents[idx] = parent; this.m_Parents = newParents; } else this.m_Parents[idx] = parent; // Adjust seed if needed. if (idx == 0) { this.m_Seed = this.m_Parents[idx].m_Seed; this.TransformSeed(); } }
public void SetValues(Layer parent, int seed) { if (parent == null) this.m_Seed = seed; else { this.m_Parents = new Layer[1] { parent }; this.m_Seed = this.m_Parents[0].m_Seed; this.TransformSeed(); } }
public static ImageTask RegenerateImageForLayerTask(FlowInterfaceControl fic, Layer l, int width, int height, Action act) { ImageTask it = new ImageTask(); Thread t = new Thread(() => { ProgressCallback callback = (progress, bitmap) => { it.Progress = progress; if (bitmap != null) { it.HasResult = true; it.Result = bitmap; } act(); }; RegenerateImageForLayer(fic, l, width, height, callback); }); t.Start(); return it; }
public LayerVoronoiMixdown(Layer voronoi, Layer parent) : base(new Layer[] { voronoi, parent }) { // Set defaults. this.EdgeSampling = 15; }