public void DrawingTest() { var template = new TileTemplate4X2(); var tile1 = new PaintedTile(1, template, new Color[] { Color.Blue, Color.Green, Color.Red, Color.Yellow }); var tile2 = new PaintedTile(2, template, new Color[] { Color.Blue, Color.Green, Color.Red, Color.Yellow }); Bitmap bitmap = new Bitmap(Convert.ToInt32(600), Convert.ToInt32(600), PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bitmap); Pen pen = new Pen(Color.Black, 2); g.Clear(Color.WhiteSmoke); g.DrawRectangle(pen, 10, 10, 10, 10); g.DrawRectangle(pen, 580, 580, 10, 10); g.TranslateTransform(100, 100); tile1.DrawTile(g); tile2.Rotation = Rotation.X000; g.TranslateTransform(80, 0); tile2.DrawTile(g); tile2.Rotation = Rotation.X090; g.TranslateTransform(80, 0); tile2.DrawTile(g); tile2.Rotation = Rotation.X180; g.TranslateTransform(80, 0); tile2.DrawTile(g); tile2.Rotation = Rotation.X270; g.TranslateTransform(80, 0); tile2.DrawTile(g); bitmap.Save(@"TileTest.png", ImageFormat.Png); }
public bool IsMatch(Direction direction, PaintedTile neighbour) { var currentBorder = this.GetRefreshedTileBorder(direction); var neighbourBorder = neighbour.GetRefreshedTileBorder(direction.GetOppositeDirection()); // checking the number of points of both borders if (currentBorder.PointColors.Length != neighbourBorder.PointColors.Length) { return(false); } // checking the colors of points on both borders for (int currentIndex = 0; currentIndex < currentBorder.PointColors.Length; currentIndex++) { var currentColor = currentBorder.PointColors[currentIndex]; // points represented in clockwise directon, but the matching point at the neighbour border is in reserved direction int neighbourIndex = currentBorder.PointColors.Length - currentIndex - 1; var neighbourColor = neighbourBorder.PointColors[neighbourIndex]; if (currentColor != neighbourColor) { return(false); } } return(true); }
public bool IsMatch(Direction direction, PaintedTile neighbour) { var currentBorder = this.GetRefreshedTileBorder(direction); var neighbourBorder = neighbour.GetRefreshedTileBorder(direction.GetOppositeDirection()); // checking the number of points of both borders if (currentBorder.PointColors.Length != neighbourBorder.PointColors.Length) { return false; } // checking the colors of points on both borders for (int currentIndex = 0; currentIndex < currentBorder.PointColors.Length; currentIndex++) { var currentColor = currentBorder.PointColors[currentIndex]; // points represented in clockwise directon, but the matching point at the neighbour border is in reserved direction int neighbourIndex = currentBorder.PointColors.Length - currentIndex - 1; var neighbourColor = neighbourBorder.PointColors[neighbourIndex]; if (currentColor != neighbourColor) { return false; } } return true; }