Function:ss2qas

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:38, 23 November 2007
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 20: Line 20:
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
 +#include <time.h>
#include "s2plot.h" #include "s2plot.h"
Line 35: Line 36:
char string[32]; char string[32];
- if (qas == 0) + if (qas == 0)
sprintf(string,"Not spinning"); /* Write to string */ sprintf(string,"Not spinning"); /* Write to string */
else else
Line 49: Line 50:
{ {
- fprintf(stderr,"Press <spacebar> to randomly change autospin state \n"); + fprintf(stderr,"Press <spacebar> to randomly change autospin state \n");
 + srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/s2mono",argc, argv); /* Open the display: mono */ s2opend("/s2mono",argc, argv); /* Open the display: mono */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
Line 55: Line 57:
cs2scb(cb); /* Install dynamic callback */ cs2scb(cb); /* Install dynamic callback */
s2show(1); /* Open the s2plot window */ s2show(1); /* Open the s2plot window */
- + 
return 1; return 1;
} }
 +
</pre></code> </pre></code>
[[S2PLOT:Function List | Back]] to S2PLOT function list. [[S2PLOT:Function List | Back]] to S2PLOT function list.
__NOTOC__ __NOTOC__
__NOEDITSECTION__ __NOEDITSECTION__

Current revision

ss2qas

Query the autospin state.

Prototype

int ss2qas(void);

Description

Query the autospin state.

See Also

ss2sasStart/Stop the camera rotation..

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

   ss2sss(50.0);                                /* Fast spinning! */
   if (lkc != *kc) {                            /* Space bar pressed? */
      if (drand48() > 0.5) ss2sas(1);           /* Random auto spin state */
      else ss2sas(0);
   }

   float qas = ss2qas();                        /* Query autospin state */
   char string[32];

   if (qas == 0)
       sprintf(string,"Not spinning");          /* Write to string */
   else
       sprintf(string,"Whee....");              /* Write to string */

   s2textxy(0,0,0,string);                      /* Display text */

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


int main(int argc, char *argv[])
{

   fprintf(stderr,"Press <spacebar> to randomly change autospin state \n");
   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/s2mono",argc, argv);               /* Open the display: mono */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */

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

   return 1;
}

Back to S2PLOT function list.


Personal tools