Function:s2sls

From S2PLOT

Jump to: navigation, search

s2sls

Set the line style.

Prototype

void s2sls(int ls);

Description

Set the line style for drawing with s2line. Codes are identical to PGPLOT:

  • 1 = solid line (default line style)
  • 2 = dashed
  • 3 = dot-dash-dot-dash
  • 4 = dotted
  • 5 = dash-dot-dot-dot

See Also

s2lineDraw a polyline with n vertices.
s2qlsQuery the line style.

Code Example

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

/* Global variables - needed in dynamic callback */
int N = 10;                     /* Number of points */
float x[10], y[10], z[10];      /* Arrays of coordinate points */

void cb(double *t, int *kc)
{
   int qls;                     /* Current line-style */
   static int ls = 0;           /* Keep track of last press */
   if (*kc != ls) {
      qls = s2qls();            /* Query line-style */
      s2sls((qls%5)+1);         /* Set a new line-style */
   }
   s2line(N, x, y, z);          /* Draw the poly-line */
   ls = *kc;                    /* Update key press count */
}

int main(int argc, char *argv[])
{
   int i;                               /* Loop variable */

   fprintf(stderr,"Press <spacebar> to change line style\n");

   srand48((long)time(NULL));           /* Seed random numbers */
   s2opend("/?",argc, argv);            /* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);      /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   for (i=0;i<N;i++) {
      x[i] = drand48()*2.0 - 1.0;       /* Random (x,y,z) coordinates */
      y[i] = drand48()*2.0 - 1.0;
      z[i] = drand48()*2.0 - 1.0;
   }

   s2sci(S2_PG_YELLOW);                 /* Set colour */
   s2slw(4);                            /* Set line width */

   cs2scb(cb);                          /* Install a dynamic callback */

   s2show(1);                           /* Open the s2plot window */

   return 1;
}

Back to S2PLOT function list.


Personal tools