Function:ns2vline

From S2PLOT

Jump to: navigation, search

ns2vline

Draw a line from one point to another in a specific colour - vector input.

Prototype

void ns2vline(XYZ P1, XYZ P2, COLOUR col);

Description

Draw a line from (P1) to (P2) with RGB colour (col), using vector data structures.

See Also

ns2line Draw a line from one point to another in a specific colour.
ns2thline Draw a thick line from one point to another in a specific colour.
ns2vthline Draw a thick line from one point to another in a specific colour - vector input.
ns2cline Draw a coloured line, with colour blended between the two given colours along the line.
ns2vcline Draw a coloured line, with colour blended between the two given colours along the line - vector input.
struct_COLOUR Data structure for (r,g,b) colour indices.
struct_XYZ Data structure for (x,y,z) coordinates.


Code Example

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

int main(int argc, char *argv[])
{
   XYZ start;      				/* Start of line */
   XYZ end;					/* End of line */
   COLOUR col;					/* Colour of line segment */
   int N = 10;					/* Number of lines */
   int i;					/* Loop variable */

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

   s2sci(S2_PG_YELLOW);				/* Set colour */
   for (i=0;i<N;i++) {
      start.x = drand48()*2.0 - 1.0;		/* Random (x,y,z) coordinates */
      start.y = drand48()*2.0 - 1.0;
      start.z = drand48()*2.0 - 1.0;
      end.x   = drand48()*2.0 - 1.0;		/* Random (x,y,z) coordinates */
      end.y   = drand48()*2.0 - 1.0;
      end.z   = drand48()*2.0 - 1.0;
      col.r   = drand48();
      col.g   = drand48();
      col.b   = drand48();
      ns2vline(start, end, col);		/* Draw the line */
   }

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

Back to S2PLOT function list.


Personal tools