Advertisement
Tyfyter

thing_that_isn't_rendering.cs

May 20th, 2019
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.93 KB | None | 0 0
  1.         public Image BGImage { get { return BackgroundImage;} set {BackgroundImage = value;} }
  2.         public static int frameindex = -1;
  3.         protected override void OnPaint(PaintEventArgs e) {
  4.             base.OnPaint(e);//so I can at least see if they start running this again
  5.             if(Name.Contains("PC")) {
  6.                 System.Console.Out.WriteLine(frameindex);//so I can see if the PC TestPictureBox starts running this again even if it's covered by something
  7.                 frameindex++;//only one thing named PC and noting else includes it, so just 1 per frame.
  8.             }
  9.             Graphics g = Main.form.border.CreateGraphics();//Main.form.border is a regular imagebox in the middle of the screen, set to be the right size for all of the tiles to fit in it
  10.             if(BGImage!=null) {
  11.                 Bitmap a1 = new Bitmap(BGImage, new Size(Width, Height));//Scale the Background images to the proper size (to support every possible resolution)
  12.                 //Bitmap a2 = new Bitmap(a, new Size(Width, Height));
  13.                 g.DrawImage(a1, (Location.X-Main.RenderPos.X)+Main.tilewidth, (Location.Y-Main.RenderPos.Y)+Main.tilewidth, Width, Height);//try to render the tile at the right location, RenderPos is the border's offset from the top-left corner.
  14.                 g.DrawImage(a1, 0, 0, Main.tilewidth, Main.tilewidth);//try to render the tile
  15.                 e.Graphics.DrawImage(a1, 0, 0, Width, Height);//try to render the tile again
  16.             }
  17.             if(Image!=null){
  18.                 ImageAttributes IAtt = new ImageAttributes();
  19.                 try {
  20.                     //IAtt.SetWrapMode(System.Drawing.Drawing2D.WrapMode.Clamp);
  21.                     ColorMatrix comat = new ColorMatrix(new float[][]
  22.                       {
  23.                          new float[] {2f, .3f, .3f, 0, 0},
  24.                          new float[] {.59f, 1f, .59f, 0, 0},
  25.                          new float[] {.11f, .11f, 1f, 0, 0},
  26.                          new float[] {1, 1, 1, 1, 1},
  27.                          new float[] {1, 1, 1, 1, 1}
  28.                      });
  29.                     IAtt.SetColorMatrix(comat);//to chech if IAtt is being used
  30.                 } catch(Exception ex) {
  31.                     Main.setText(ex.Message);
  32.                 }
  33.                 Bitmap a = (Bitmap)Image;
  34.                 a = new Bitmap(a, new Size(Width, Height));//try to fix size
  35.                 Point[] points = new Point[3];
  36.                 points[0] = new Point((Location.X-Main.RenderPos.X)+Main.tilewidth, (Location.Y-Main.RenderPos.Y)+Main.tilewidth);
  37.                 Point point = new Point(points[0].X, points[0].Y)+new BetterPoint(Width, Height);//BetterPoint is just Point, but it supports being used as a 2d vector that starts at 0,0, and it supports converting between the result of 0 seconds of neural network training and the Xna framework's almost unnecessary but usable points, all due to being programmed for a reason.
  38.                 points[1] = new Point(point.X,points[0].Y);
  39.                 points[2] = new Point(points[0].X,point.Y);//try to create a point array with the right format, probably fails due to using instructions from the exeption thrown with only 2 instead of some random person answering stackoverflow questions while listening to "Rasputin" at 2 AM.
  40.                 g.DrawImage(a, points, new Rectangle(0,0,Image.Width-1,Image.Height-1),System.Drawing.GraphicsUnit.Pixel, IAtt);//try to render the image
  41.                 e.Graphics.DrawImage(a, new Point[] {new Point(),new Point(), new Point()}, new Rectangle(0,0,Image.Width-1,Image.Height-1), GraphicsUnit.Pixel, IAtt);//just trying to see if anything was working here, it wasn't
  42.                 //e.Graphics.DrawImage(a, new Point[]{new Point(0,0),new Point(0,16),new Point(0,16)}, new Rectangle(0,0,Image.Width-1,Image.Height-1),System.Drawing.GraphicsUnit.Pixel, IAtt);//trying that again, failing it again
  43.                 //e.Graphics.Dispose();
  44.             }
  45.             //if(Name!=null)g.DrawImage(Main.Letter[Name.ToLower().ToCharArray()[0]], Location.X/2, Location.Y/2);//try to render first letter of Control name
  46.             g.Dispose();
  47.             e.Graphics.Dispose();
  48.         }
  49.  
  50.     public class BetterPoint{//see?
  51.         int X;
  52.         int Y;
  53.         public BetterPoint(int X,int Y){this.X=X; this.Y=Y;}
  54.         public static BetterPoint operator+ (BetterPoint a, BetterPoint b){
  55.             return new BetterPoint(a.X+b.X,a.Y+b.Y);
  56.         }
  57.         public static implicit operator Point(BetterPoint i){
  58.             return new Point(i.X,i.Y);
  59.         }
  60.         public static implicit operator Microsoft.Xna.Framework.Point(BetterPoint i){
  61.             return new Microsoft.Xna.Framework.Point(i.X,i.Y);
  62.         }
  63.         public static implicit operator BetterPoint(Point i){
  64.             return new BetterPoint(i.X,i.Y);
  65.         }
  66.         public static implicit operator BetterPoint(Microsoft.Xna.Framework.Point i){
  67.             return new BetterPoint(i.X,i.Y);
  68.         }
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement