Function:ss2qar

From S2PLOT

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

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

Line 1: Line 1:
-==ss2qas==+==ss2qar==
-Query the autospin state.+Query the aspect ratio.
==Prototype== ==Prototype==
<code><pre> <code><pre>
-int ss2qas(void);+float ss2qar(void);
</pre></code> </pre></code>
==Description== ==Description==
-Query the autospin state. +Query the aspect ratio: returned value is ratio of width to height, ie. it is normally > 1.
== See Also == == See Also ==
<table> <table>
-<tr><td>[[Function:ss2sas | ss2sas]]</td><td>Start/Stop the camera rotation..</td><td> </td></tr>+<tr><td>[[Function:s2open | s2open]]</td><td>Open the S2PLOT device. </td></tr>
 +<tr><td>[[Function:s2opend | s2opend]]</td><td>Open the S2PLOT device (device string version). </td></tr>
 +<tr><td>[[Function:s2opendo | s2opendo]]</td><td>Open the S2PLOT device (device string version, ignoring command line arguments). </td></tr>
 +<tr><td>[[Function:s2ldev | s2ldev]]</td><td>List the available S2PLOT devices on stdout. </td></tr>
</table> </table>
Line 24: Line 27:
void cb(double *t, int *kc) void cb(double *t, int *kc)
{ {
- static int lkc = 0; /* Count of key presses */+ float qar = ss2qar(); /* Query the aspect ratio */
- + char string[32];
- ss2sss(50.0); /* Fast spinning! */+ sprintf(string,"aspect ratio = %.2f",qar); /* Write to string */
- 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 */ s2textxy(0,0,0,string); /* Display text */
- 
- lkc = *kc; /* Update count */ 
} }
- 
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
 + fprintf(stderr,"Resize window to see change in aspect ratio");
- fprintf(stderr,"Press <spacebar> to randomly change autospin state \n"); + s2opend("/s2mono", argc, argv); /* Open in mono mode */
- 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 */
- + s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
 +
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;
} }

Current revision

ss2qar

Query the aspect ratio.

Prototype

float ss2qar(void);

Description

Query the aspect ratio: returned value is ratio of width to height, ie. it is normally > 1.

See Also

s2openOpen the S2PLOT device.
s2opendOpen the S2PLOT device (device string version).
s2opendoOpen the S2PLOT device (device string version, ignoring command line arguments).
s2ldevList the available S2PLOT devices on stdout.

Code Example

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

void cb(double *t, int *kc)
{
   float qar = ss2qar();                        /* Query the aspect ratio */
   char string[32];                     
   sprintf(string,"aspect ratio = %.2f",qar);   /* Write to string */
   s2textxy(0,0,0,string);                      /* Display text */
}

int main(int argc, char *argv[])
{
   fprintf(stderr,"Resize window to see change in aspect ratio");

   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