コード例 #1
0
 /// <summary>
 /// Constructs a new instance of <see cref="TrackableObjectChangedEventArgs"/> from the specified values.
 /// </summary>
 /// <param name="newPosition">The <see cref="NewPosition"/>.</param>
 /// <param name="oldPosition">The <see cref="OldPosition"/>.</param>
 /// <param name="newSize">The <see cref="NewSize"/>.</param>
 /// <param name="oldSize">The <see cref="OldSize"/>.</param>
 public TrackableObjectChangedEventArgs(PointF newPosition, PointF oldPosition, SizeF newSize, SizeF oldSize)
 {
     NewPosition = newPosition;
     OldPosition = oldPosition;
     NewSize = newSize;
     OldSize = oldSize;
 }
コード例 #2
0
ファイル: PointFTests.cs プロジェクト: EBrown8534/Framework
        public void CreatePointFStructure_0_1f_1_56f()
        {
            var expectedX = 0.1f;
            var expectedY = 1.56f;

            PointF point = new PointF(0.1f, 1.56f);

            Assert.AreEqual(expectedX, point.X);
            Assert.AreEqual(expectedY, point.Y);
        }
コード例 #3
0
ファイル: PointFTests.cs プロジェクト: EBrown8534/Framework
        public void CreatePointFStructure_0_0f_0_0f()
        {
            var expectedX = 0.0f;
            var expectedY = 0.0f;

            PointF point = new PointF(0.0f, 0.0f);

            Assert.AreEqual(expectedX, point.X);
            Assert.AreEqual(expectedY, point.Y);
        }
コード例 #4
0
ファイル: PointTests.cs プロジェクト: EBrown8534/Framework
        public void Round_0_1f_1_56f()
        {
            var expectedX = 0x00;
            var expectedY = 0x02;

            PointF point = new PointF(0.1f, 1.56f);
            Point rounded = Point.Round(point);

            Assert.AreEqual(expectedX, rounded.X);
            Assert.AreEqual(expectedY, rounded.Y);
        }
コード例 #5
0
ファイル: LineTests.cs プロジェクト: EBrown8534/Framework
        public void Intersect_OnePositive_OneNegative_Line_0_0_2_2_Line_2_0_0_2()
        {
            // \  /
            //  \/
            //  /\
            // /  \
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(2, 0), new Point(0, 2));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
ファイル: LineTests.cs プロジェクト: EBrown8534/Framework
        public void Intersect_OneHorizontal_OnePositive_Line_0_0_2_2_Line_0_1_2_1()
        {
            //    /
            // __/_
            //  /
            // /
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(0, 1), new Point(2, 1));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
ファイル: LineTests.cs プロジェクト: EBrown8534/Framework
        public void Intersect_OneVertical_OnePositive_Line_0_0_2_2_Line_1_0_1_2()
        {
            //   |/
            //   |
            //  /|
            // / |
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(1, 0), new Point(1, 2));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
ファイル: LineTests.cs プロジェクト: EBrown8534/Framework
        public void Intersect_BothPositive_Line_0_0_2_2_Line_1_0_2_2()
        {
            //   _/
            // _//
            //  /
            // /
            var expected = new PointF(2f, 2f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(1, 0), new Point(2, 2));

            var actual = Line.Intersect(l1, l2);

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
ファイル: PointF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Offsets a <see cref="PointF"/> by the specified <see cref="SizeF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> that should be offset.</param>
 /// <param name="sz">The <see cref="SizeF"/> to offset by.</param>
 /// <returns>A new <see cref="PointF"/> that has been offset.</returns>
 public static PointF Add(PointF pt, SizeF sz) => pt + sz;
コード例 #10
0
ファイル: Camera.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Updates the <see cref="Position"/> of the current <see cref="Camera"/> instance to the value specified.
 /// </summary>
 /// <param name="position">A <see cref="PointF"/> representing the new <see cref="Position"/> of the <see cref="Camera"/>.</param>
 public void SetPosition(PointF position)
 {
     Position = position;
 }
コード例 #11
0
ファイル: Line.cs プロジェクト: EBrown8534/Framework
 public bool WithinY(PointF pt) => (pt.Y >= Start.Y && pt.Y <= End.Y) || (pt.Y <= Start.Y && pt.Y >= End.Y);
コード例 #12
0
ファイル: Line.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Determines if the <see cref="Bounds"/> contains the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to test.</param>
 /// <returns>True if the <see cref="PointF"/> fits in the current <see cref="Bounds"/>.</returns>
 /// <remarks>
 /// If it is already know that the <see cref="PointF"/> fits on the <see cref="Line"/> at <b>some</b> location, then this is an inexpensive operation to see if the <see cref="PointF"/> is within the current <see cref="Line"/> segment.
 /// </remarks>
 public bool RectContainsPoint(PointF pt) => WithinX(pt) && WithinY(pt);
コード例 #13
0
ファイル: PointShort.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all values down to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded down.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Truncate(PointF value) => new PointShort((short)(value.X), (short)(value.Y));
コード例 #14
0
ファイル: PointShort.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all float values up to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded up.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Ceiling(PointF value) => new PointShort((short)Math.Ceiling(value.X), (short)Math.Ceiling(value.Y));
コード例 #15
0
ファイル: PointTests.cs プロジェクト: EBrown8534/Framework
        public void Truncate_0_1f_1_56f()
        {
            var expectedX = 0x00;
            var expectedY = 0x01;

            PointF point = new PointF(0.1f, 1.56f);
            Point rounded = Point.Truncate(point);

            Assert.AreEqual(expectedX, rounded.X);
            Assert.AreEqual(expectedY, rounded.Y);
        }
コード例 #16
0
ファイル: Point.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all values to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Round(PointF value) => new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));
コード例 #17
0
ファイル: Point.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all float values up to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded up.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Ceiling(PointF value) => new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));
コード例 #18
0
ファイル: Point.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all values down to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded down.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Truncate(PointF value) => new Point((int)(value.X), (int)(value.Y));
コード例 #19
0
ファイル: RectangleF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Determines if a <see cref="PointF"/> is contained within the current <see cref="RectangleF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to test.</param>
 /// <returns>True if pt is contained within this <see cref="RectangleF"/>.</returns>
 public bool Contains(PointF pt) => Contains(pt.X, pt.Y);
コード例 #20
0
ファイル: RectangleF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new instance of <see cref="RectangleF"/> from the specified <see cref="PointF"/> and <see cref="SizeF"/>.
 /// </summary>
 /// <param name="location">The <see cref="Location"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="size">The <see cref="Size"/> of the <see cref="RectangleF"/>.</param>
 public RectangleF(PointF location, SizeF size)
 {
     Location = location;
     Size = size;
 }
コード例 #21
0
ファイル: PointShort.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all values to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Round(PointF value) => new PointShort((short)Math.Round(value.X), (short)Math.Round(value.Y));
コード例 #22
0
ファイル: RectangleF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Moves this <see cref="RectangleF"/> by the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pos">The <see cref="PointF"/> containing the values to move by.</param>
 /// <returns>A new <see cref="RectangleF"/> moved by the <see cref="PointF"/> values.</returns>
 public RectangleF Offset(PointF pos) => new RectangleF(new PointF(Location.X + pos.X, Location.Y + pos.Y), Size);
コード例 #23
0
ファイル: Line.cs プロジェクト: EBrown8534/Framework
 public Line(PointF start, PointF end)
 {
     Start = start;
     End = end;
     Vector = new Vector2F(End.X - Start.X, End.Y - Start.Y);
 }
コード例 #24
0
ファイル: RectangleF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new instance of <see cref="RectangleF"/> from the specified <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/> and <see cref="Height"/>.
 /// </summary>
 /// <param name="x">A value representing the <see cref="X"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="y">A value representing the <see cref="Y"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="width">A value representing the <see cref="Width"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="height">A value representing the <see cref="Height"/> of the <see cref="RectangleF"/>.</param>
 public RectangleF(float x, float y, float width, float height)
 {
     Location = new PointF(x, y);
     Size = new SizeF(width, height);
 }
コード例 #25
0
ファイル: Line.cs プロジェクト: EBrown8534/Framework
 public bool WithinX(PointF pt) => (pt.X >= Start.X && pt.X <= End.X) || (pt.X <= Start.X && pt.X >= End.X);
コード例 #26
0
ファイル: SizeF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Constructs a new instance of <see cref="SizeF"/> from the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to construct the <see cref="SizeF"/> from.</param>
 /// <remarks>
 /// The <see cref="PointF.X"/> will become the <see cref="Width"/> and the <see cref="PointF.Y"/> will be the <see cref="Height"/>.
 /// </remarks>
 public SizeF(PointF pt)
 {
     Width = pt.X;
     Height = pt.Y;
 }
コード例 #27
0
ファイル: Camera.cs プロジェクト: EBrown8534/Framework
 private void trackObject_TrackableObjectChanged(object sender, TrackableObjectChangedEventArgs e)
 {
     // We should make the new camera position the same as the position of the entity, minus the centering
     _position = new PointF((e.NewPosition.X + e.NewSize.Width) / 2.0f - RelativeCenter.X, (e.NewPosition.Y + e.NewSize.Height) / 2.0f - RelativeCenter.Y);
 }
コード例 #28
0
ファイル: LineTests.cs プロジェクト: EBrown8534/Framework
        public void Intersect_OneVertical_OneHorizontal_Line_1_0_1_2_Line_0_1_2_1()
        {
            //   |
            // __|_
            //   |
            //   |
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(1, 0), new Point(1, 2));
            var l2 = new Line(new Point(0, 1), new Point(2, 1));

            var actual = Line.Intersect(l1, l2);

            Assert.AreEqual(expected, actual);
        }
コード例 #29
0
ファイル: Camera.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Alters the <see cref="Position"/> of the current <see cref="Camera"/> instance by the specified <see cref="Vector2F"/>.
 /// </summary>
 /// <param name="vector">The distance to move the <see cref="Camera"/>.</param>
 public void MoveCamera(Vector2F vector)
 {
     Position = new PointF(Position.X + vector.X, Position.Y + vector.Y);
 }
コード例 #30
0
ファイル: PointF.cs プロジェクト: EBrown8534/Framework
 /// <summary>
 /// Subtracts a <see cref="PointF"/> by a <see cref="SizeF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to be subtracted from.</param>
 /// <param name="sz">The <see cref="SizeF"/> to subtract.</param>
 /// <returns>A <see cref="PointF"/> representing the difference.</returns>
 public static PointF Subtract(PointF pt, SizeF sz) => pt - sz;