SetViewportOrg and setjavasworg

Source: Internet
Author: User

Author: xqscorpion)

Address: http://xqscorpion.bokee.com/5172295.html

Set window origin to (x, y) indicates to set the coordinate origin to (x, y); that is, (x, y) is used as the coordinate origin. At this time, the origin coordinate is no longer (0, 0 );
Set window origin as (x, y) indicates to change the coordinates of the original origin point (0, 0) to (x, y); To increase the coordinates of all vertices (+ x, + y );

Now I understand that it should be set window origin to (x, y ). This understanding is based on the following prerequisites:
1. All the coordinates given in all drawing statements are logical coordinates, that is, the coordinates in the window (relative to the device coordinates represented by viewport );
2. the device coordinates of all the points that users can see must be within the range of (0, 0) and (1024,768). (assuming that the display is an output device, MM_TEXT ing is used, and the screen resolution is 1024*768 );
3. The so-called "(0, 0) is the origin, and the coordinates of the origin must be (0, 0)" is wrong;
4. The coordinates in Viewport indicate the device coordinates; the coordinates in Window indicate the logical coordinates;
5. after a new origin point is specified in the logical coordinate, the origin point of the device coordinate must overlap with that of the logical coordinate when the ing is executed, that is, the origins of the two coordinate systems must overlap.

The following is an example: (MM_TEXT ing mode)

(1)
CRect rect (0, 0,200,200 );
Dc. rectangle (rect );
The preceding statement draws a square in the upper left corner of the screen (because the logical coordinate and the device coordinate are not offset at this time)

(2)
Dc. SetViewportOrg (100,100 );
CRect rect (0, 0,200,200 );
Dc. rectangle (rect );
Set the origin of the device coordinate to (100,100). That is, the origin of the device coordinate is not (0, 0), but in (100,100). If the ing is performed, the origin (0, 0) of the logical coordinate must overlap with the origin (100,100) of the device coordinate (refer to premise 5); then the rectangle (0, 0,200,200) drawn at this time) the coordinates (logical coordinates, refer to premise 1) in the device coordinates will be mapped to (100,100,300,300), and eventually we will see an offset (100,100) to the bottom right of the display) A square with a side length of 200 (the point you see is in the device coordinate, refer to premise 2)

(3)
Dc. set0000worg (100,100 );
CRect rect (0, 0,200,200 );
Dc. rectangle (rect );
Set the origin of the logical coordinate to (100,100). That is, the origin of the logical coordinate is not (0, 0), but in (100,100). If the ing is performed, the origin (0, 0) of the device coordinate must overlap with the origin (100,100) of the logical coordinate (refer to premise 5); then the rectangle (0, 0,200,200) drawn at this time) the coordinates (logical coordinates, refer to premise 1) in the device coordinates will be mapped to (-100,-100,100,100 ), what we see on the display is a part of a rectangle of only 1/4 sizes (in fact, it is equivalent to a square with a side length of 100,100 shifted to the top left (200. Note: The point you see is in the device coordinate. Refer to prerequisite 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.