Ejemplo n.º 1
0
 public void Translate(float dx, float dy)
 {
     for (int i = 0; i < points.Count; ++i)
     {
         AffineTransformer t = new AffineTransformer(AffineMatrix.FromPoint(points[i]));
         t.Translate(dx, dy);
         points[i] = t.GetResult().ToPoint();
     }
     RaiseChangedEvent(PolygonChangeType.PointsChanged);
 }
Ejemplo n.º 2
0
 public void Rotate(float angle, PointF point)
 {
     for (int i = 0; i < points.Count; ++i)
     {
         AffineTransformer t = new AffineTransformer(AffineMatrix.FromPoint(points[i]));
         t.Translate(-point.X, -point.Y);
         t.Rotate(angle);
         t.Translate(point.X, point.Y);
         points[i] = t.GetResult().ToPoint();
     }
     RaiseChangedEvent(PolygonChangeType.PointsChanged);
 }
Ejemplo n.º 3
0
        public void Scale(float width, float height)
        {
            float sumX = 0, sumY = 0;

            for (int i = 0; i < points.Count; ++i)
            {
                sumX += points[i].X;
                sumY += points[i].Y;
            }
            PointF transPoint = new PointF(sumX / points.Count, sumY / points.Count);

            for (int i = 0; i < points.Count; ++i)
            {
                AffineTransformer t = new AffineTransformer(AffineMatrix.FromPoint(points[i]));
                t.Translate(-transPoint.X, -transPoint.Y);
                t.Scale(width, height);
                t.Translate(transPoint.X, transPoint.Y);
                points[i] = t.GetResult().ToPoint();
            }
            RaiseChangedEvent(PolygonChangeType.PointsChanged);
        }