private void clearButton_Click(object sender, EventArgs e) { timer1.Enabled = false; pictureBox1.Image = null; _prevPoint = new Tuple <int, int>(215, 150); _res = CellAutomata.turmite(CellAutomata.state.A, ConsoleColor.Black, 215, 150, CellAutomata.dir.East); _drawArea = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height); _timer1.Enabled = false; }
private void InitializeCellAutomat() { _prevPoint = new Tuple <int, int>(215, 150); _res = CellAutomata.turmite(CellAutomata.state.A, ConsoleColor.Black, 215, 150, CellAutomata.dir.East); _timer1.Tick += timer1_Tick; _timer1.Interval = _speed; _timer1.Enabled = false; _drawArea = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height); }
private void timer1_Tick(object sender, EventArgs e) { pictureBox1.Image = _drawArea; _drawArea.SetPixel(_prevPoint.Item1, _prevPoint.Item2, ColorFromConsoleColor(_res.Item2)); var c = _drawArea.GetPixel(_res.Item3.Item1, _res.Item3.Item2); var colorName = GetKnownColorName(c.R, c.G, c.B); var color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), (colorName == "Fuchsia" ? "Magenta" : colorName)); _prevPoint = new Tuple <int, int>(_res.Item3.Item1, _res.Item3.Item2); _res = CellAutomata.turmite(_res.Item1, color, _res.Item3.Item1, _res.Item3.Item2, _res.Item4); }