Function:s2qah

From S2PLOT

Jump to: navigation, search

s2qah

Query the arrow-head style.

Prototype

void s2qah(int *fs, float *angle, float *barb);

Description

Query the arrow-head style.

See Also

s2sahSet the arrow-head style.
s2arro Draw an arrow from the point with world-coordinates (x1,y1,z1) to (x2,y2,z2).

Code Example

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"

void cb(double *t, int *kc)
{
   static int lkc = 0;                          /* Count of key presses */
   int filled = 1;                              /* Arrow fill style */

   if (lkc != *kc) {                            /* Space bar pressed? */
      s2sah(filled, drand48()*130+5.0, drand48()*0.95+0.05);
                                                /* Choose random arrow format */
   }

   int fs;                                      /* Fill style */
   float angle, barb;                           /* Arrow parameters */
   s2qah(&fs, &angle, &barb);                   /* Query arrow paramters */

   char string[32];
   sprintf(string,"Arrow (angle,barb) = (%.2f, %.2f)",angle,barb);
                                                /* Write to string */
   s2textxy(0,0,0,string);                      /* Display text */

   s2sch(4);                                    /* Control size of arrowhead */
   float x[2], y[2], z[2];
   x[0] = -0.8; y[0] = -0.4; z[0] = 0.0;        /* Coordinates of line */
   x[1] = +0.8; y[1] = -0.4; z[1] = 0.0;
   s2arro(x[0],y[0],z[0], x[1],y[1],z[1]);      /* Draw the arrow */
   s2sch(1);                                    /* Reset size for text */

   lkc = *kc;                                   /* Update count */
}

int main(int argc, char *argv[])
{
   fprintf(stderr,"Press the <spacebar> to change arrow parameters");

   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/s2mono", argc, argv);              /* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   cs2scb(cb);                                  /* Install dynamic callback */
   s2show(1);                                   /* Open the s2plot window */

   return 1;
}

Back to S2PLOT function list.


Personal tools