Function:s2qch

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:41, 27 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 30: Line 31:
} }
- float qch = s2qch(); /* Query character height */+ float qch = s2qch(); /* Query character height */
- char string[32]; + char string[32];
- sprintf(string,"Height = %.2f",qch); /* Write to string */+ sprintf(string,"Height = %.2f",qch); /* Write to string */
- s2textxy(-1,0,0,string); /* Display text */+ s2textxy(-1,0,0,string); /* Display text */
lkc = *kc; /* Update count */ lkc = *kc; /* Update count */
Line 42: Line 43:
fprintf(stderr,"Press the <spacebar> to change character height"); fprintf(stderr,"Press the <spacebar> to change character height");
 + srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/s2mono", argc, argv); /* Open in mono mode */ s2opend("/s2mono", argc, argv); /* Open in mono mode */
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 */ 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 */
Line 51: Line 53:
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

s2qch

Query the character height.

Prototype

float s2qch(void);

Description

Query the characer height.

See Also

s2schSet the character height

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? */
      s2sch(drand48()*5+1);             /* Choose random height */
   }

   float qch = s2qch();                 /* Query character height */
   char string[32];
   sprintf(string,"Height = %.2f",qch); /* Write to string */
   s2textxy(-1,0,0,string);             /* Display text */

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

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

   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