public static void DrawRectangle(this IDebugCanvas canvas, IntRect2 nodeRect, float z, StrokeStyle strokeStyle)
 {
     canvas.DrawLineStrip(
         new [] {
         new DoubleVector3(nodeRect.Left, nodeRect.Top, z),
         new DoubleVector3(nodeRect.Right, nodeRect.Top, z),
         new DoubleVector3(nodeRect.Right, nodeRect.Bottom, z),
         new DoubleVector3(nodeRect.Left, nodeRect.Bottom, z),
         new DoubleVector3(nodeRect.Left, nodeRect.Top, z)
     }, strokeStyle);
 }
示例#2
0
        public static IHoleStaticMetadata CreateRectangleHoleMetadata(int x, int y, int width, int height, double rotation)
        {
            var contour   = Polygon2.CreateRect(-width / 2, -height / 2, width, height).Points;
            var transform = Matrix3x2.CreateRotation((float)rotation);

            contour = contour.Map(p => Vector2.Transform(p.ToDoubleVector2().ToDotNetVector(), transform).ToOpenMobaVector().LossyToIntVector2())
                      .Map(p => p + new IntVector2(x, y))
                      .ToList();

            var bounds = IntRect2.BoundingPoints(contour.ToArray()).ToDotNetRectangle();

            return(new PrismHoleStaticMetadata(bounds, new[] { new Polygon2(contour) }));
        }
示例#3
0
        private static void RenderVisualizationFrame()
        {
            var segments = Util.Generate(200, RandomSegment);

            var(ax, ay) = RandomPoint();
            var(bx, by) = RandomPoint();
            var rect = new IntRect2(Math.Min(ax, bx), Math.Min(ay, by), Math.Max(ax, bx), Math.Max(ay, by));
            //var rect = new IntRect2(Math.Min(ax, bx), Math.Min(ay, by), Math.Min(ax, bx), Math.Max(ay, by));
            //var rect = new IntRect2(segments[0].X1, segments[0].Y1, segments[0].X1, segments[0].Y1);

            var canvas = host.CreateAndAddCanvas(frameCounter++);

            canvas.BatchDraw(() => {
                canvas.DrawRectangle(rect, 0, StrokeStyle.BlackHairLineSolid);
                foreach (var s in segments)
                {
                    canvas.DrawLine(s.First, s.Second, rect.ContainsOrIntersects(s) ? StrokeStyle.LimeHairLineDashed5 : StrokeStyle.RedHairLineDashed5);
                }
            });
        }
 // todo: this is probablby wrong, sorry.
 public static Rectangle ToDotNetRectangle(this IntRect2 r) => new Rectangle(r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top);