Function:s2qlw

From S2PLOT

Revision as of 06:21, 6 March 2008; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

s2qlw

Query the line width.

Prototype

int s2qlw(void);

Description

Query the line width.

See Also

s2slwSet the line width

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 */

   if (lkc != *kc) {                            /* Space bar pressed? */
     //s2slw(drand48()*10+1);                   /* Choose random linewidth */
     s2slw((float)rand() / (float)RAND_MAX * 10. + 1.);
   }

   int qlw = s2qlw();                           /* Query line width */
   char string[32];
   sprintf(string,"line width = %d",qlw);       /* Write to string */
   s2textxy(0,0,0,string);                      /* Display text */

   int N = 2;                                   /* Number of points in line */
   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;
   s2line(N, x, y, z);                          /* Draw the line */

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

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

   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