//Events private void Canvas_Load(object sender, EventArgs e) { //Get the image dimensions WidthHeightDialog dialog = new WidthHeightDialog(); dialog.ShowDialog(); //Create the image and picbox image = new Heightmap(dialog.width, dialog.height); tempPicBox.Image = image.ToBitmap(); //Enable the timer tickTimer.Enabled = true; //Set default brush params brushSpeedBox.Minimum = (decimal)MIN_BRUSH_SPEED; brushSpeedBox.Maximum = (decimal)MAX_BRUSH_SPEED; brushSize = DEFAULT_SIZE; brushSpeed = DEFAULT_SPEED; //Add all brush types AddBrushType("Circle", new CircleBrush()).Checked = true; AddBrushType("Square", new SquareBrush()); //Add all tools AddTool("Paint Brush", PaintBrushTool).Checked = true; AddTool("Eraser", EraserTool); }
public ImageFileNode(NodeMap map, Heightmap heightmap) : base(map) { //Creates one from a pre-existing heightmap. image = heightmap.ToBitmap(); this.heightmap = heightmap; }
private void generateButton_Click(object sender, EventArgs e) { //Get the data from the textboxes int width; int height; int seed; int octave; double persistence; double frequency; double lacunarity; //Catch any errors with the textboxes try { width = int.Parse(widthBox.Text); height = int.Parse(heightBox.Text); seed = int.Parse(seedBox.Text); octave = int.Parse(OctBox.Text); Double.TryParse(PersBox.Text, out persistence); Double.TryParse(LacBox.Text, out lacunarity); Double.TryParse(FreqBox.Text, out frequency); } catch (FormatException err) { MessageBox.Show("ERROR: width, height, seed, and octave count must all be integers.\r\nPersistence, lacunarity, and frequency are doubles"); return; } catch (OverflowException err) { MessageBox.Show("ERROR: One of your values is too long."); return; } //Generate the preview map previewMap = new Heightmap(width, height); PerlinNoise noiseGen = new PerlinNoise(seed, octave, frequency, lacunarity, persistence); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { double value = noiseGen.GetValue((double)x, (double)y) * Heightmap.MAX_HEIGHT; previewMap.SetValue(x, y, value); } } //Update the preview picture previewBox.Image = previewMap.ToBitmap(); //Enable the Okay button OKButton.Enabled = true; }
//Misc functions private void UpdateDisplay() { //TODO: Do this more efficiently. tempPicBox.Image = image.ToBitmap(); }
private void button1_Click(object sender, EventArgs e) { //Reset the image image = new Heightmap(image.width, image.height); tempPicBox.Image = image.ToBitmap(); }
public override Bitmap ToBitmap() { return(heightmap.ToBitmap()); }