-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
74 lines (62 loc) · 1.54 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using RTFP.DataStructures;
using RTFP.DataStructures.Geometry;
using RTFP.Generator.FloorPlan;
namespace RTFP
{
static class Program
{
static void Main()
{
SuburbanGenerator generator = new SuburbanGenerator();
while (true)
{
FloorPlan fp = generator.GenerateFloorPlan();
DrawFloorPlan(fp);
}
}
private static void DrawFloorPlan(FloorPlan fp)
{
int width = 252, height = 252;
Brush[] brushes = new Brush[]
{
Brushes.Gray,
Brushes.DarkGray,
Brushes.LightGray,
Brushes.LightSlateGray,
Brushes.BurlyWood
};
// Create our canvas to work with
var font = new Font("Arial", 8);
var bmp = new Bitmap(width, height);
var gfx = Graphics.FromImage(bmp);
gfx.FillRectangle(Brushes.White, new RectangleF(0, 0, width, height));
// Draw rooms and their types
for(int i = 0; i < fp.Rooms.Count; i++)
{
var r = fp.Rooms[i];
gfx.FillRectangle(brushes[i % brushes.Length], r.X, r.Y, r.Width, r.Height);
gfx.DrawRectangle(Pens.Black, new Rectangle(new Point(r.X, r.Y), new Size(r.Width, r.Height)));
gfx.DrawString(r.Type.ToString(), font, Brushes.Black, r.X, r.Y);
}
// Display form
var form = new Form() { AutoSize = true };
form.Controls.Add
(
new PictureBox()
{
Width = width,
Height = height,
Image = bmp,
Location = new Point(5, 5)
}
);
form.ShowDialog();
}
}
}