Example #1
0
        private HPoint[] GetOutlinedRect(HPoint p1, HPoint p2, int outline)
        {
            /*     p1
             *   +--+--+
             *    \  \  \
             *     \  \  \
             *      +--+--+
             *         p2   p2+len
             *
             */
            if (p1 == p2)
            {
                return new[] { p1, p1, p1, p1 };
            }

            var pt1 = new Point2D(p1.X, p1.Y);
            var pt2 = new Point2D(p2.X, p2.Y);
            var vector = Vector2D.FromPoints(pt2, pt1);
            var points = new[]{
                new Point2D(-outline,0),
                new Point2D(0,outline),
                new Point2D(vector.Length,outline),
                new Point2D(vector.Length+outline,0),
                new Point2D(vector.Length,-outline),
                new Point2D(0,-outline),
                new Point2D(-outline,0),
            };
            var rotated = points.Select(pt => pt1.Add(pt.Rotate(vector.Angle))).Select(pt => new HPoint((int)pt.X, (int)pt.Y)).ToArray();
            return rotated;
        }
Example #2
0
 public Point2D Add(Point2D p2)
 {
     return new Point2D(X + p2.X, Y + p2.Y);
 }
Example #3
0
 public Size2D Sub(Point2D p2)
 {
     return new Size2D(X-p2.X, Y-p2.Y);
 }
Example #4
0
 public static Vector2D FromPoints(Point2D p1, Point2D p2)
 {
     return new Vector2D(new Size2D(p1.X - p2.X, p1.Y - p2.Y));
 }