Пример #1
0
        public object Visit(Polygon shape, RenderInfo info)
        {
            Canvas  c   = info.Canvas;
            Vector2 pos = this.Entity.Position;

            Vector2[] verts = shape.RotatedVertices(this.Entity.Orientation);
            c.Begin();
            c.MoveTo(pos + verts[verts.Length - 1]);
            for (int i = 0; i < verts.Length; i++)
            {
                c.LineTo(pos + verts[i]);
            }
            if (this.fill.A > 0)
            {
                c.FillColor = this.fill;
                c.Fill();
            }
            if (this.stroke.A > 0)
            {
                c.StrokeColor = this.stroke;
                c.LineWidth   = this.thickness;
                c.Stroke();
            }

#if DEBUG
            Matrix rot = Matrix.CreateRotationZ(this.Entity.Orientation);
            for (int i = 0; i < shape.normals.Length; i++)
            {
                c.Begin();
                c.MoveTo(pos);
                c.LineTo(pos + Vector2.TransformNormal(shape.normals[i], rot) * shape.RoughRadius * 1.5f);
                c.StrokeColor = Color.Green;
                c.LineWidth   = this.thickness;
                c.Stroke();
            }

            for (int i = 0; i < shape.projections.Length; i++)
            {
                c.Begin();
                c.MoveTo(pos + Vector2.TransformNormal(shape.normals[i], rot) * shape.projections[i].Max);
                c.LineTo(pos + Vector2.TransformNormal(shape.normals[i], rot) * shape.projections[i].Min);
                c.StrokeColor = Color.Blue;
                c.LineWidth   = this.thickness;
                c.Stroke();
            }
#endif
            return(null);
        }
Пример #2
0
 private void DrawVector(Canvas canvas, Vector2 start, Vector2 end, string name)
 {
     Vector2 unit = end - start;
     if (unit.Length() > 0.1f)
     {
         unit.Normalize();
         Vector2 right = unit.RightPerproduct();
         canvas.Begin();
         canvas.MoveTo(start);
         canvas.LineTo(end);
         canvas.MoveTo(end - unit * 5 + right * 5);
         canvas.LineTo(end);
         canvas.LineTo(end - unit * 5 - right * 5);
         canvas.LineWidth = this.defaultLineWidth*3;
         canvas.StrokeColor = DebugLayer.Shadow;
         canvas.Stroke();
         canvas.LineWidth = this.defaultLineWidth;
         canvas.StrokeColor = GetColor(name);
         canvas.Stroke();
     }
 }