Advertisement
kolya5544

DVD Logo stuff?

Jun 21st, 2020
1,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.90 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Runtime.InteropServices;
  4.  
  5. namespace SPSharp
  6. {
  7.  
  8.     class Program
  9.     {
  10.         public struct RECT
  11.         {
  12.             public double x, y, w, h;
  13.  
  14.             public RECT(double a, double b, double c, double d)
  15.             {
  16.                 x = a; y = b; w = c; h = d;
  17.             }
  18.         };
  19.  
  20.  
  21.         public static bool contains(RECT R1, RECT R2)
  22.         {
  23.             if ((R2.x + R2.w) < (R1.x + R1.w)
  24.                 && (R2.x) > (R1.x)
  25.                 && (R2.y) > (R1.y)
  26.                 && (R2.y + R2.h) < (R1.y + R1.h)
  27.                 )
  28.             {
  29.                 return true;
  30.             }
  31.             else
  32.             {
  33.                 return false;
  34.             }
  35.         }
  36.         [DllImport("user32.dll", SetLastError = false)]
  37.         static extern IntPtr GetDesktopWindow();
  38.         [DllImport("user32.dll")]
  39.         static extern IntPtr GetWindowDC(IntPtr hWnd);
  40.         [DllImport("user32.dll")]
  41.         static extern bool GetCursorPos(ref Point POINT);
  42.         [DllImport("user32.dll")]
  43.         static extern int ShowCursor(bool b);
  44.         public static int Handler(int direction,int X, int Y, int W, int H, int SW, int SH)
  45.         {
  46.             if (contains(new RECT(0, 0, SW, SH), new RECT(X, Y, W, H)))
  47.             {
  48.                 return -1;
  49.             } else
  50.             {
  51.                 /* 1                      2
  52.                  *
  53.                  *
  54.                  *
  55.                  * 3                      4
  56.                  *
  57.                  */
  58.                 Point first = new Point(X, Y);
  59.                 Point second = new Point(X+W, Y);
  60.                 Point third = new Point(X, Y + H);
  61.                 Point fourth = new Point(X + W, Y + H);
  62.                 if (third.Y >= SH || fourth.Y >= SH)
  63.                 {
  64.                     if (direction == 1) return 2;
  65.                     if (direction == 3) return 4;
  66.                 } else if (first.X <= 0 || third.X <= 0)
  67.                 {
  68.                     if (direction == 4) return 2;
  69.                     if (direction == 3) return 1;
  70.                 } else if (first.Y <= 0 || second.Y <= 0)
  71.                 {
  72.                     if (direction == 2) return 1;
  73.                     if (direction == 4) return 3;
  74.                 } else if (second.X >= SW || fourth.X >= SW)
  75.                 {
  76.                     if (direction == 1) return 3;
  77.                     if (direction == 2) return 4;
  78.                 }
  79.  
  80.             }
  81.             return -1;
  82.         }
  83.  
  84.         static void Main(string[] args)
  85.         {
  86.             Graphics g = Graphics.FromHdc(GetWindowDC(GetDesktopWindow()));
  87.             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
  88.             Image test = new Bitmap("bruh.png");
  89.             g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
  90.  
  91.            
  92.             int direction = 3;
  93.             /* 1 = X++, Y++ -> v
  94.              * 2 = X++, Y-- -> ^
  95.              * 3 = X--, Y++ <- v
  96.              * 4 = X--, Y-- <- ^
  97.              */
  98.             int W = (int)g.VisibleClipBounds.Width;
  99.             int H = (int)g.VisibleClipBounds.Height;
  100.             int X = W/2;
  101.             int Y = H/2;
  102.             double hi = 0;
  103.             while (true)
  104.             {
  105.  
  106.                 g.DrawImage(test, X, Y);
  107.                 var r = Handler(direction, X,Y,test.Width, test.Height, W,H);
  108.                 if (r != -1)
  109.                 {
  110.                     direction = r;
  111.                 }
  112.                 switch (direction)
  113.                 {
  114.                     case 1:
  115.                         X+=4;Y+=4;break;
  116.                     case 2:
  117.                         X+=4;Y-=4;break;
  118.                     case 3:
  119.                         X-=4;Y+=4;break;
  120.                     case 4:
  121.                         X-=4;Y-=4;break;
  122.                 }
  123.             }
  124.         }
  125.     }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement