ArticleThe C # drawing mode and zoom function are described in detail. In entity modeling software, various coordinate systems can be set and stored independently and called at any time.
In entity modeling software, various reference coordinate systems are often set and saved to facilitate model creation. C # similar functions are also available in plotting. But not as powerful as modeling software. In entity modeling software, various coordinate systems can be set and stored independently and called at any time. However, it can only be called in the form of nesting. When it is returned to the upper-level status, the skipped status will not be saved.
C # Main commands for drawing common mode:
-
- State = graphics. begincontainer (); Create a New Drawing state
-
- E. Graphics. endcontainer (state1); ends the drawing state.
-
- Rectangle rect = new rectangle (0, 0,100,100); // sample image
-
-
-
- Graphicscontainer state1 =
-
- E. Graphics. begincontainer (); // create a new drawing coordinate state1
-
- E. Graphics. translatetransform (100,100 );
-
- // Move the coordinate system to 100,100 and draw a blue rectangle mark
-
- E. Graphics. drawrectangle (pens. Blue, rect );
-
-
-
- Graphicscontainer state2 =
- E. Graphics. begincontainer (); // create a plot coordinate state2 based on this
-
- E. Graphics. rotatetransform (45); // rotate 45 degrees, draw a red rectangle mark
-
- E. Graphics. drawrectangle (pens. Red, rect );
-
- E. Graphics. translatetransform (100,100 );
-
- E. Graphics. drawrectangle (pens. Black, rect );
-
- E. Graphics. endcontainer (state2); // exit Coordinate System 2, draw a blue Ellipse
-
-
-
- E. Graphics. drawellipse (pens. Blue, rect );
-
- E. Graphics. endcontainer (state1); // exit state1 and draw a red elliptic
-
- E. Graphics. drawrectangle (pens. Red, rect );
Status 1
Move to 100,100 and draw a blue rectangle
Nested state 2
Move to, 0, and draw a red rectangle
Exit status 2, draw a blue oval
Exit status 1, draw a red rectangle
Status 2 is nested. If you exit status 1 and draw a red rectangle, status 2 is no longer saved.
Graphics. begincontainer () and endgontainer are used to save and return the current canvas status. Of course, moving is only a way to change the canvas status.
C # Main commands for drawing and Scaling:
- Graphicscontainer containerstate =
- E. Graphics. begincontainer (destrect, srcrect, graphicsunit. pixel );
-
- // Add two more parameters. destrect and scrrect specify the zooming size. pixel specifies the unit.
- Rectangle srcrect = newrectangle (0, 0, 200,200 );
- Rectangle destrect = newrectangle (200,200,100,100); // create a scaled picture board.
- Graphicscontainer containerstate = E. Graphics. begincontainer (
- Destrect, srcrect, graphicsunit. pixel); // plot the scaled green rectangle.
- E. Graphics. fillrectangle (newsolidbrush (color. Red), 100,100,); // exit the drawing board.
- E. Graphics. endcontainer (containerstate); // draws the original red rectangle.
- E. Graphics. fillrectangle (newsolidbrush (color. Green), 0, 0, 100,100 );
The above introduces the C # drawing mode and zoom function.