/[dotgnu-pnet]/pnetlib/System.Drawing/Drawing2D/Matrix.cs
ViewVC logotype

Diff of /pnetlib/System.Drawing/Drawing2D/Matrix.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by drobosson, Fri Dec 17 12:16:12 2004 UTC revision 1.8 by drobosson, Tue Jan 4 10:32:22 2005 UTC
# Line 36  public sealed class Matrix : MarshalByRe Line 36  public sealed class Matrix : MarshalByRe
36                                  dx  = 0.0f;                                  dx  = 0.0f;
37                                  dy  = 0.0f;                                  dy  = 0.0f;
38                          }                          }
         [TODO]  
39          public Matrix(Rectangle rect, Point[] plgpts)          public Matrix(Rectangle rect, Point[] plgpts)
40                          {                          {
41                                  // TODO                                  RectangleF rectF = new RectangleF (
42                                                    (float)rect.X,
43                                                    (float)rect.Y,
44                                                    (float)rect.Width,
45                                                    (float)rect.Height
46                                                    );
47                                    PointF[] plgptsF = null;
48                                    if ( plgpts != null )
49                                    {
50                                            plgptsF = new PointF[plgpts.Length];
51                                            for ( int i=0; i<plgpts.Length; i++ )
52                                            {
53                                                    plgptsF[i] = new PointF(
54                                                                    (float)(plgpts[i].X),
55                                                                    (float)(plgpts[i].Y)
56                                                                    );
57                                            }
58    
59    
60                                    }
61                                    TransfRect2Poly( rectF, plgptsF );
62                          }                          }
         [TODO]  
63          public Matrix(RectangleF rect, PointF[] plgpts)          public Matrix(RectangleF rect, PointF[] plgpts)
64                            {
65                                    TransfRect2Poly( rect, plgpts );
66                            }
67            // helper method, computes transformation from rectangle rect to polygon  plgpts
68            private void TransfRect2Poly(RectangleF rect, PointF[] plgpts)
69                          {                          {
70                                  // TODO                                  // check if plgpts defines a polygon with 3 points
71                                    if ( (plgpts == null) || (plgpts.Length != 3) )
72                                            throw new ArgumentException("plgpts");
73                                    // check if rect is degenerated
74                                    if ( (rect.Width == 0.0f) || (rect.Height == 0.0f) )
75                                            throw new ArgumentOutOfRangeException("rect");
76                                    // compute transformation of rect to plgpts
77                                    PointF v1 = new PointF(
78                                                    plgpts[1].X - plgpts[0].X,
79                                                    plgpts[1].Y - plgpts[0].Y
80                                                    );
81                                    PointF v2 = new PointF(
82                                                    plgpts[2].X - plgpts[0].X,
83                                                    plgpts[2].Y - plgpts[0].Y
84                                                    );
85                                    this.dx = plgpts[0].X-rect.X/rect.Width*v1.X-rect.Y/rect.Height*v2.X;
86                                    this.dy = plgpts[0].Y-rect.X/rect.Width*v1.Y-rect.Y/rect.Height*v2.Y;
87                                    this.m11 = v1.X / rect.Width ;
88                                    this.m12 = v1.Y / rect.Width ;
89                                    this.m21 = v2.X / rect.Height ;
90                                    this.m22 = v2.Y / rect.Height ;
91                          }                          }
92                                                    
93          public Matrix Clone()          public Matrix Clone()

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26