You will need
- The programming environment of Turbo Pascal
Disassemble the specified object for drawing into its components. Highlight individual lines, arcs, circles, rectangles, and points. These figures can be drawn using the procedures of Turbo Pascal.
At the beginning of the program code connect the graphics module. To do this, write the line: uses graph. Next, create integer variables to initialize graphics mode: var gdet, gm: integer.
In the body of the program, after the keyword begin, initialize variables, giving one of them a zero value and the second value to detect. Next, specify the startup graphic drawing mode, enter the line: initgraph(gdet, gm, "). Clean the device for outputting graphical data: cleardevice.
Set the background color for drawing and the color of the lines drawn objects. Use this procedure SetBkColor(white) and SetColor(8). In brackets you can set the color. Pascal only uses 16 colors, and each of them is set to either the numeral or the word from the special color table.
Draw yourself a grid of the screen, where the x-axis from left to right and the y axis runs from top to bottom. At the beginning of this coordinate system, i.e. in the upper left corner of the screen is coordinate (0,0). Calculate the coordinates of the desired position of the first graphical object. All coordinates for drawing shapes set in the system.
Draw a line by using the procedure line(x,y,x1,Y1) where the coordinates x, y are the start point of the line and x1, Y1 is the end of her. If necessary, change the thickness or line type. For this procedure SetLineStyle(0,0,NormWidth). The first parameter of the procedure to change the line, making it touch the dotted line – change this number to 1 or 2. The third parameter specifies the thickness of lines. The default is always set to NormWidth - thin lines, thick lines, put ThickWidth. Changed the line type will be drawn after calling this procedure.
Put a dot on the screen using the procedure PutPixel(x, y, color) here x and y are the coordinates of the point and color is its color. Before drawing a closed shape, you can specify its fill. To do this, call the procedure SetFillStyle (EmptyFill, 0), where the first parameter specifies a solid fill of the shape, and the second specifies the fill color.
Rectangle shape is drawn by the procedure Rectangle(x,y,x2,y2) – coordinates specify the upper left and lower right corners of the figure. For drawing circle, line Circle(x, y, R), where x, y, R coordinates of the center and the radius of the circle, all in pixels. Ellipse to draw harder, it uses much more parameters: Ellipse(x, y, BegA, EndA, RX, RY). Here x, y is the same the center of the ellipse, and BegA and EndA indicate the angle on which you want to start an elliptical arc and finish it. Variables RX, RY specify the radius of the ellipse along the axis x and y respectively.
If you have a specified figure of the drawing which is easiest to hold the individual segments, use the procedure MoveTo and LineTo. First set the current cursor to the desired point: MoveTo (x, y). Then slide it out of the line to the next point LineTo(x1, Y1) and again draw a straight line LineTo(x2, Y2) and so until then yet will not receive the original figure.
At the end of the drawing in code, close the graphics mode string: closegraph. Complete the body of the program, as usual, by end. Now the code can be compiled and run.
The graphics in Pascal.Animation. Dynamic drawings of Turbo Pascal. Draw an ellipse at any angle. Curves according to the equation. What you need to know to create images in Turbo P...
Using special procedures and functions you can draw simple primitives, such as circle, square, etc.