コード例 #1
0
 //Add a printable to existing bitmap
 public void PrintOnImage(Printable p, Bitmap image)
 {
     using (Graphics graph = Graphics.FromImage(image))
     {
         TextureBrush tBrush = p.Brush as TextureBrush;
         if (tBrush != null)
         {
             Image imageFromTexture = ((TextureBrush)p.Brush).Image;
             tBrush = new TextureBrush(ResizeImage(imageFromTexture, p.PxSize, p.PxSize));
             for (int i = 0; i < p.Width * p.PxSize; i += p.PxSize)
             {
                 for (int j = 0; j < p.Height * p.PxSize; j += p.PxSize)
                 {
                     Rectangle ImageSize = new Rectangle(p.X * p.PxSize + i, p.Y * p.PxSize + j, tBrush.Image.Width, tBrush.Image.Height);
                     graph.FillRectangle(tBrush, ImageSize);
                 }
             }
         }
         else
         {
             Rectangle ImageSize = new Rectangle(p.X * p.PxSize, p.Y * p.PxSize, p.Width * p.PxSize, p.Height * p.PxSize);
             graph.FillRectangle(p.Brush, ImageSize);
         }
     }
 }
コード例 #2
0
ファイル: DungeonMap.cs プロジェクト: Rinfor/DungeonTools
        private bool CheckCollisions(Printable printable)
        {
            bool      collide   = false;
            Rectangle rectangle = new Rectangle(printable.X, printable.Y, printable.Width, printable.Height);

            foreach (Room r in Rooms)
            {
                Rectangle auxRentangle = new Rectangle(r.X, r.Y, r.Width, r.Height);
                if (rectangle.IntersectsWith(auxRentangle))
                {
                    collide = true;
                    break;
                }
            }
            if (collide)
            {
                return(collide);
            }
            foreach (Corridor c in Corridors)
            {
                Rectangle auxRentangle = new Rectangle(c.X, c.Y, c.Width, c.Height);
                if (rectangle.IntersectsWith(auxRentangle))
                {
                    collide = true;
                    break;
                }
            }
            return(collide);
        }
コード例 #3
0
        //Creates a bitmap from printable
        public Bitmap Print(Printable p)
        {
            Bitmap bmp = new Bitmap(p.Width * p.PxSize, p.Height * p.PxSize);

            if (p.Brush != null)
            {
                using (Graphics graph = Graphics.FromImage(bmp))
                {
                    Rectangle ImageSize = new Rectangle(0, 0, p.Width * p.PxSize, p.Height * p.PxSize);
                    graph.FillRectangle(p.Brush, ImageSize);
                }
            }
            return(bmp);
        }