當前位置: 首頁>>代碼示例>>C#>>正文


C# Point.GetDistance方法代碼示例

本文整理匯總了C#中System.Point.GetDistance方法的典型用法代碼示例。如果您正苦於以下問題:C# Point.GetDistance方法的具體用法?C# Point.GetDistance怎麽用?C# Point.GetDistance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Point的用法示例。


在下文中一共展示了Point.GetDistance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Ok_Vin_Click

 private void Ok_Vin_Click(object sender, EventArgs e)
 {
     BackUps.Add(pictureBox1.Image.Clone() as Bitmap);
     Index++;
     var IB = pictureBox1.Image as Bitmap;
     using (var img = new ImagerBitmap(IB))
     {
         var Center = new Point(img.Width / 2,img.Height / 2);
         for (int x = 0; x < img.Width; x++)
             for (int y = 0; y < img.Height; y++)
             {
                 var pix = img.GetPixel(x, y);
                 if (Center.GetDistance(new Point(x, y)) + Center.GetDistance(new Point(0, 0))/(10 - trackBar1.Value) > Center.GetDistance(new Point(0, 0)))
                 {
                     img.SetPixel(x, y, Color.Black);
                 }
             }
         pictureBox1.Image = img.Bitmap;
     }
 }
開發者ID:1extra,項目名稱:prog2015,代碼行數:20,代碼來源:Form1.cs

示例2: ClipViewPosition

		public override void ClipViewPosition(Point p)
		{
			if (ViewPositionLock != null)
			{
				p.x = ViewPositionLock.x;
				p.y = ViewPositionLock.y;

				return;
			}

			var Walls = this.Map.WallMap;

			if (Walls == null)
				return;

			Func<Point, double, bool> RadialBump =
				(vp, vr) =>
				{

					var z = p.GetDistance(vp);

					if (z < vr)
					{
						// pump us out of that sprite

						var a = (p - vp).GetRotation();

						p.x = vp.x + Math.Cos(a) * vr;
						p.y = vp.y + Math.Sin(a) * vr;

						return true;
					}
					else
					{
						return false;
					}
				};


			#region bump on blocking sprites
			if (EnableBlockingSprites)
				foreach (var v in BlockingSprites)
				{
					RadialBump(v.Position, v.Range);
				}
			#endregion

			var fPlayerX = p.x;
			var fPlayerY = p.y;


			var c = new PointInt32
			{
				X = (int)Math.Floor(p.x),
				Y = (int)Math.Floor(p.y)
			};

			var TILE_SIZE = 1.0;

			var PositionInWall =
				 new Point
				 {
					 x = fPlayerX % TILE_SIZE,
					 y = fPlayerY % TILE_SIZE
				 };


			var TileTop = Walls[c.X, c.Y - 1];
			var TileLeft = Walls[c.X - 1, c.Y];
			var TileRight = Walls[c.X + 1, c.Y];
			var TileBottom = Walls[c.X, c.Y + 1];


			var CurrentMapTile = Walls[c.X, c.Y];

			if (CurrentMapTile != 0)
			{
				// we are inside a wall
				// push us out of there

				#region Dia
				var A = PositionInWall.x > PositionInWall.y;
				var B = PositionInWall.x > (TILE_SIZE - PositionInWall.y);

				var DiaClipLeft = !A && !B;
				var DiaClipRight = A && B;
				var DiaClipTop = A && !B;
				var DiaClipBottom = !A && B;
				#endregion

				#region Alt
				var C = PositionInWall.x > (TILE_SIZE / 2);
				var D = PositionInWall.y > (TILE_SIZE / 2);

				var AltClipTopLeft = !C && !D;
				var AltClipBottomLeft = !C && D;
				var AltClipTopRight = C && !D;
				var AltClipBottomRight = C && D;
				#endregion

//.........這裏部分代碼省略.........
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:101,代碼來源:ViewEngine.BlockingSprites.cs

示例3: Tycoon4


//.........這裏部分代碼省略.........
            #region StartLoadingDudeAnimationInfo
            Action<DudeAnimationInfo> StartLoadingDudeAnimationInfo =
                a =>
                {
                    a.Frames_Stand.ForEach(i => StartLoadingSingleImage(i.Image));
                    a.Frames_Walk.ForEach(j => j.ForEach(i => StartLoadingSingleImage(i.Image)));
                };
            #endregion

            var Argh = new Argh();
            var CloneAffirmative = new EN_000002();
            var Affirmative = new Affirmative();
            var click = new click();
            var Hammertime = new SAMPLES234 { volume = 0.1 };
            var Sawtime = new SAMPLES216 { volume = 0.1 };
            var StoneHammerTime = new SAMPLES233 { volume = 0.1 };


            #endregion

            #region AllImagesLoaded
            AllImagesLoaded +=
                delegate
                {
                    Console.WriteLine("AllImagesLoaded");

                    info.innerText = "Loading images... done!";

                    #region Translate
                    Func<double, double, Point<double>> Translate =
                        (_x, _y) =>
                        {
                            var _r = ZeroPoint.GetRotation(_x, _y) + RotationA;
                            var _d = ZeroPoint.GetDistance(_x, _y) * bg_size.h * 2d.Sqrt();

                            _x = Math.Cos(_r) * _d;
                            _y = Math.Sin(_r) * _d * RotationB;

                            return new Point<double> { X = _x, Y = _y };
                        };
                    #endregion

                    #region Translator
                    var Translator = new CoordTranslatorBase
                    {
                        ConvertMapToCanvas = map_coords =>
                        {
                            var canvas_coords = Translate(map_coords.X, map_coords.Y);
                            var c = GetCenter();

                            canvas_coords.X += c.X;
                            canvas_coords.Y += c.Y;

                            return canvas_coords;

                        },
                        ConvertCanvasToMap = canvas =>
                        {
                            var c = GetCenter();

                            var offset = new Point<double> { X = canvas.X - c.X, Y = (canvas.Y - c.Y) / RotationB };

                            var d = ZeroPoint.GetDistance(offset) / (bg_size.h * 2d.Sqrt());
                            var r = ZeroPoint.GetRotation(offset) - RotationA;

                            var realoffset = new Point<double>
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:67,代碼來源:Tycoon4.cs

示例4: Distance1

		public void Distance1()
		{
			var a = new Point(0, 1);
			var b = new Point(0, 0);
			var distance = (int)a.GetDistance(b);
			Assert.AreEqual(1, distance);
		}
開發者ID:GoogleFrog,項目名稱:Zero-K-Infrastructure,代碼行數:7,代碼來源:ExtensionTests.cs

示例5: Shorten

 public void Shorten(Point fixedPoint, ref Point translatedPoint)
 {
     var length = translatedPoint.GetDistance(fixedPoint);
     var newLength = length - ArrowOffset;
     var ratio = newLength / length;
     var x = (int)(fixedPoint.X + ratio * (translatedPoint.X - fixedPoint.X));
     var y = (int)(fixedPoint.Y + ratio * (translatedPoint.Y - fixedPoint.Y));
     translatedPoint = new Point(x, y);
 }
開發者ID:GoogleFrog,項目名稱:Zero-K-Infrastructure,代碼行數:9,代碼來源:LinkDrawing.cs


注:本文中的System.Point.GetDistance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。