Function:ss2qbc
From S2PLOT
(Difference between revisions)
| Revision as of 02:32, 23 November 2007 S2plot admin (Talk | contribs) ← Previous diff |
Revision as of 02:32, 23 November 2007 S2plot admin (Talk | contribs) Next diff → |
||
| Line 1: | Line 1: | ||
| - | ==s2qci== | + | ==ss2sbc== |
| - | Query the colour index. | + | Query the background colour. |
| ==Prototype== | ==Prototype== | ||
| <code><pre> | <code><pre> | ||
| - | int s2qci(void); | + | void ss2qbc(float *r, float *g, float *b); |
| </pre></code> | </pre></code> | ||
| ==Description== | ==Description== | ||
| - | Query the colour index. | + | Query the background colour. |
| == See Also == | == See Also == | ||
| Line 18: | Line 18: | ||
| ==Code Example== | ==Code Example== | ||
| <code><pre> | <code><pre> | ||
| + | #include <stdio.h> | ||
| + | #include <stdlib.h> | ||
| + | #include "s2plot.h" | ||
| + | void cb(double *t, int *kc) | ||
| + | { | ||
| + | static int lkc = 0; /* Count of key presses */ | ||
| + | |||
| + | if (lkc != *kc) { /* Space bar pressed? */ | ||
| + | ss2sbc(drand48(), drand48(), drand48()); /* Random background colour */ | ||
| + | } | ||
| + | float r, g, b; | ||
| + | ss2qbc(&r, &g, &b); /* Query background colour */ | ||
| + | |||
| + | s2scr(100,1-r,1-g,1-b); | ||
| + | s2sci(100); | ||
| + | char string[32]; | ||
| + | sprintf(string,"Colour = (%.2f,%.2f,%.2f)",r,g,b); /* Write to string */ | ||
| + | s2textxy(0,-0.5,0,string); /* Display text */ | ||
| + | |||
| + | lkc = *kc; /* Update count */ | ||
| + | } | ||
| + | |||
| + | int main(int argc, char *argv[]) | ||
| + | { | ||
| + | fprintf(stderr,"Press the <spacebar> to change background colour"); | ||
| + | |||
| + | 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; | ||
| + | } | ||
| </pre></code> | </pre></code> | ||
| [[S2PLOT:Function List | Back]] to S2PLOT function list. | [[S2PLOT:Function List | Back]] to S2PLOT function list. | ||
| __NOTOC__ | __NOTOC__ | ||
| __NOEDITSECTION__ | __NOEDITSECTION__ | ||
Revision as of 02:32, 23 November 2007
ss2sbc
Query the background colour.
Prototype
void ss2qbc(float *r, float *g, float *b);
Description
Query the background colour.
See Also
| ss2sbc | Set the background colour. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"
void cb(double *t, int *kc)
{
static int lkc = 0; /* Count of key presses */
if (lkc != *kc) { /* Space bar pressed? */
ss2sbc(drand48(), drand48(), drand48()); /* Random background colour */
}
float r, g, b;
ss2qbc(&r, &g, &b); /* Query background colour */
s2scr(100,1-r,1-g,1-b);
s2sci(100);
char string[32];
sprintf(string,"Colour = (%.2f,%.2f,%.2f)",r,g,b); /* Write to string */
s2textxy(0,-0.5,0,string); /* Display text */
lkc = *kc; /* Update count */
}
int main(int argc, char *argv[])
{
fprintf(stderr,"Press the <spacebar> to change background colour");
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.
