Radio Animations
The following functions are provided for animating wireless (ex. radio) connections.
- draw_beam - This displays a colored line from the source (transmitter) to the destination (receiver). Supply the source and destination coordinates, a color, and a thickness. To remove, simply re-issue the call with the same coordinates and color. The formal definition of the function is:
``` void draw_beam( float pos_x1, float pos_y1, float pos_x2, float pos_y2, int color, float thickness );
```
Thickness of 1.0 is normal. Thickness of 2.0 is double-thick. - draw_ring - This makes a circle or ring to show the coverage of a transmission from a radio. Supply the center-origin as the transmitter's location, a radius, and a color. To remove, simply re-issue the call with the same coordinates and color. The formal definition of the function is:
``` void draw_ring( float pos_x1, float pos_y1, float radius, int color );
```
Example -
- draw_ring2 - Advanced version of draw_ring having many additional settings.
This makes a partial ring of arbitrary thickness and number of segments to show the coverage and direction of a transmission from a radio.
Supply the center-origin as the transmitter's location, radius, color, the number of segments to draw (normally 28 for 360-deg ring),
the thickness of the ring (normally 1.0), the angle subtended (in radians) for
showing directional beams (normally 2Pi for omni), and the pointing direction (in
radians, (0 radians is East, Pi/2 is South).
To remove, simply re-issue the call with the *exact* same parameters.
The formal definition of the function is:
``` void draw_ring2( float pos_x1, float pos_y1, float radius, int color, int nsegs, float thickness, float ang, float point );
```
Example -
Colors can be specified by number or name. Available colors are listed in the Color Table.
The functions are automatically stubbed for textual (non-graphical) simulations. (You do not have to #ifdef them away.) The above functions are intended to replace the earlier function paint_beam, which erased underlying objects.
The following functions are provided for moving radio (or any box or entity) positions on the screen.
- MY_POSITION - Gets an objects position and size in canvas coordinates, by supplying the object's instance name. The formal definition of the function is:
``` void MY_POSITION( char *obj_name, float *pos_x, float *pos_y, float *xsz, float *ysz )
```
The coordinates can then be used to erase the object and move it to new coordinates. - place_box - Draw object in stationary color format. Often used to erase an object at its original location by setting to background color (0). The formal definition of the function is:
``` void place_box( float pos_x1, float pos_y1, float pos_x2, float pos_y2, int color )
``` - draw_box - Draw object in moveable color format. Used to both draw an object at a new location, and to erase its old position. The formal definition of the function is:
void draw_box( float pos_x, float pos_y, float xsz, float ysz, int color );
Example - Using the above functions to move a box:
/* Get the box's initial position. /
MY_POSITION( MY_NAME, &posx, &posy, &szx, &szy );
/* First (once) erase the permanent box, and redraw moveable version. */
place_box( posx, posy, szx, szy, 0 );
draw_box( posx, posy, szx, szy, Green );
While (forever)
{
DELAY(1.0);
/* Erase the box's old location by toggling draw with exact old values. */
draw_box( posx, posy, szx, szy, Green );
/* Update the object's new position somehow. */
posx = trajectory_x(CSIM_TIME);
posy = trajectory_y(CSIM_TIME);
/* Draw the box at the new location. */
draw_box( posx, posy, szx, szy, Green );
}

