コード例 #1
0
 // Auxiliary functions. TransAffineResizing() modifier sets up the resizing
 // matrix on the basis of the given Width and Height and the initial
 // Width and Height of the window. The implementation should simply
 // call this function every time when it catches the resizing event
 // passing in the new values of Width and Height of the window.
 // Nothing prevents you from "cheating" the scaling matrix if you
 // call this function from somewhere with wrong arguments.
 // TransAffineResizing() accessor simply returns current resizing matrix
 // which can be used to apply additional scaling of any of your
 // stuff when the window is being resized.
 // Width(), Height(), InitialWidth(), and InitialHeight() must be
 // clear to understand with no comments :-)
 public void TransAffineResizing(int width, int height)
 {
     if ((m_window_flags & (uint)EWindowFlags.KeepAspectRatio) != 0)
     {
         double sx = (double)(width) / (double)(m_initial_width);
         double sy = (double)(height) / (double)(m_initial_height);
         if (sy < sx)
         {
             sx = sy;
         }
         m_resize_mtx = Affine.NewScaling(sx, sx);
         Transform.Viewport vp = new Transform.Viewport();
         vp.PreserveAspectRatio(0.5, 0.5, Pictor.Transform.Viewport.EAspectRatio.Meet);
         vp.DeviceViewport(0, 0, width, height);
         vp.WorldViewport(0, 0, m_initial_width, m_initial_height);
         m_resize_mtx = vp.ToAffine();
     }
     else
     {
         m_resize_mtx = Affine.NewScaling(
             (double)(width) / (double)(m_initial_width),
             (double)(height) / (double)(m_initial_height));
     }
 }
コード例 #2
0
 // Auxiliary functions. TransAffineResizing() modifier sets up the resizing
 // matrix on the basis of the given Width and Height and the initial
 // Width and Height of the window. The implementation should simply
 // call this function every time when it catches the resizing event
 // passing in the new values of Width and Height of the window.
 // Nothing prevents you from "cheating" the scaling matrix if you
 // call this function from somewhere with wrong arguments.
 // TransAffineResizing() accessor simply returns current resizing matrix
 // which can be used to apply additional scaling of any of your
 // stuff when the window is being resized.
 // Width(), Height(), InitialWidth(), and InitialHeight() must be
 // clear to understand with no comments :-)
 public void TransAffineResizing(int width, int height)
 {
     if ((m_window_flags & (uint)EWindowFlags.KeepAspectRatio) != 0)
     {
         double sx = (double)(width) / (double)(m_initial_width);
         double sy = (double)(height) / (double)(m_initial_height);
         if (sy < sx) sx = sy;
         m_resize_mtx = Affine.NewScaling(sx, sx);
         Transform.Viewport vp = new Transform.Viewport();
         vp.PreserveAspectRatio(0.5, 0.5, Pictor.Transform.Viewport.EAspectRatio.Meet);
         vp.DeviceViewport(0, 0, width, height);
         vp.WorldViewport(0, 0, m_initial_width, m_initial_height);
         m_resize_mtx = vp.ToAffine();
     }
     else
     {
         m_resize_mtx = Affine.NewScaling(
             (double)(width) / (double)(m_initial_width),
             (double)(height) / (double)(m_initial_height));
     }
 }