| | | | ' Scale factor: 100 logical unit per monitor inch SetWindowExtEx pic.hdc, 100, 100, sz SetViewportExtEx pic.hdc, PixPerInchX, PixPerInchY, sz ' Draw lines For i = 1 to 4 ' Move current point to logical origin MoveToEx pic.hdc, 0, 0, pt ' Draw ray of radius 100 logical units LineTo pic.hdc, 100 * Cos(1.57 * i / 5), 100 * Sin(1.57 * i / 5) Next | | | | | | To draw the ellipses, we change the logical coordinate system. Note that we flip about the x-axis, even though this is not really necessary, since the ellipses are symmetric about this axis. | | | | | | ' No initial translation SetWindowOrgEx pic.hdc, 0, 0, pt ' Final Translation from (0,0) logical to midpoint of picture box SetViewportOrgEx pic.hdc, (pic.Width / 2) / Screen.TwipsPerPixelX, _ (pic:Height / 2) / Screen.TwipsPerPixelY, pt ' Scale factor set to 8 logical units per monitor inch horizontally ' Set vertical scale to flatten ellipses by 2 to 1 ' Reflect about x-axis (this is not really necessary) SetWindowExtEx pic.hdc, 8, 16, sz SetViewportExtEx pic.hdc, PixPerInchX, -PixPerInchY, sz ' Draw ellipses For i = 1 To 5 Ellipse pic.hdc, -i, -i, i, i Next i ' Restore DC RestoreDC pic.hdc, hDCPic | | | | | | In the previous examples, we were able to set the origins and extents to any values. This was permitted by setting the mapping mode to MM_ANISOTROPIC: | | | | | | SetMapMode pic.hdc, MM_ANISOTROPIC | | | | | | However, in many cases, we do not need this much freedom. For instance, we may want to scale the two axes proportionally, to preserve the aspect ratio (ratio of unit lengths on the two axes). This will guarantee that a circle or square drawn in page space will be mapped to a circle or square in physical space. | | | | | | To accommodate a variety of common situations, Windows defines several mapping modes. These determine who gets to set the various origins and extents Windows or the programmer. | | |