Online Tutorial - Introduction to the 2d graphics


Objectives Objects and operations with graphics. 2D-visualization.
Main information The objects for working with 2D-graphics are in the library GRAPH2D.LIB. These are a line, a polyline, a text, a raster picture, a triangle, a rectangle etc. To work with these objects the window that can be created by object LGSpace or GraphicSpace is needed. To get the window with the object you need use the variables HSpace or WindowName. But it is necessary to do that only in case when several windows are open. If only one window is open the images work automatically. All objects have the following variables:
name              type purpose
WindowName STRING window name
HSpace HANDLE graphic space descriptor
ObjectName STRING graphic object name (for work with soon existing object)
HObject HANDLE graphic object descriptor
Show FLOAT graphic object visibility flag
Exercise 1 Start Stratum 2000 and create a  new project. Insert the GraphicSpace object (library Unit). Then insert the Rectangle object (library Graph2d). Set variable values x,y (the coordinates of the top left angle) and the Width, Height. Set a line and filling color (PencColor, BrushColor). Then press the Start button button3.gif (174 bytes)..

l10_1.gif (11328 bytes)

Then try to change the variables values  x, y, Width, Height, Pencolor, Brushcolor without stopping the scheme.

Exercise 2 Insert the object Ellipse. Set the coordinates, radiuses and other variables. Put the object Arrow, Pie, Triangle, Picture on the scheme too. Use help to get the variables description. For that right-click on the object, you are interested in, on the scheme and choose the line Help on class. Let the scheme run after a new image was set. Do not forget to press the Stop button button4.gif (180 bytes) to set variables values needed for every start.
Create a new object and type the formula describing the object moving on the plane there. For example:

x:=100+80*sin(t)
y:=100+80*cos(t)
t:=t+0.01

Give its variables x and y to the object Rectangle.

l10_2.gif (6124 bytes)

Try to control the color. For that type in the created object:

color:= RGB(rnd(255), rnd(255), rnd(255))

Give the variable color to the variable Brushcolor of object Rectangle. Try to type the formula changing color under the certain function. Invent yourself some mathematical functions to change the variables of different graphical objects (the line width, the fill or border color, the points coordinates). Insert object Polyline to plot a graph of any mathematical depending or to map the moving trajectory. (for example you can link its variables x and y with the same of object Rectangle).

Exercise 3 Try to control any graphical image variables with the help of images VSlider and Hslider (library Control).

Back : Index : Forward

Trademarks & Copyright © 1998 Stratum Modeling Group.  Last modified on 6-January-1999.