JEXI design (10) coordinate conversion

zhaozj2021-02-16  102

Coordinate conversion (revision)

View saves (Offsetx, Offset "indicates the starting coordinates of the document relative to the view.

Documents require this starting coordinate when drawing, indicating that the entire document should be drawn from here.

The above figure:

Viewwidth-docwidth <= offsetx <= 0ViewHeight-Docheight <= Offsety <= 0

If the view is larger than the document:

Offsetx = (ViewWidth - DocWidth) / 2Offsety = (ViewHeight - ViewHeight) / 2

View 4 important values ​​about the document: DOCWIDTH, DOCHEIGHT, OFFSETX, OFFSETY

Convert the coordinates of the view to document coordinates:

INT TRANSTODOC (INT X) {??? Return X OffsetX;}

Int transportoc (int y) {??? Return Y offsety;}

Drawing operation start coordinates of documents are determined by Offsetx, Offsety:

Void View :: UpdateView (graphics g) {??? g.moveto (offsetx, offsety); ??? Document.draw (g);}

转载请注明原文地址:https://www.9cbs.com/read-10889.html

New Post(0)