Function:ds2vtb

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:07, 30 October 2007
S2plot admin (Talk | contribs)

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

Line 13: Line 13:
Draw text at position iP that faces the camera with vector inputs. Use this function only from within a dynamic callback. The components of iOff are in character units along Right and Up vectors - use this to displace labels in screen coordinates. If scaletext is true (non-zero), then text further from the camera will be made larger so that labels are equally legible for all distances. Draw text at position iP that faces the camera with vector inputs. Use this function only from within a dynamic callback. The components of iOff are in character units along Right and Up vectors - use this to displace labels in screen coordinates. If scaletext is true (non-zero), then text further from the camera will be made larger so that labels are equally legible for all distances.
-NOTE: this function uses the S2PLOT attributes for character height (size) and colour. The z component of ioff is ignored. +NOTES
 +* This function uses the S2PLOT attributes for character height (size) and colour. The z component of ioff is ignored.
 +* If your text does does not appear, try setting the x and y values of ioff to something small, e.g ioff.x = ioff.y = 0.01.
== See Also == == See Also ==
Line 70: Line 72:
} }
- s2scb(cb); /* Install a dynamic callback */+ cs2scb(cb); /* Install a dynamic callback */
s2show(1); /* Open the s2plot window */ s2show(1); /* Open the s2plot window */

Current revision

ds2vtb

Draw text that always faces the camera - vector input

Prototype

void ds2vtb(XYZ iP, XYZ ioff, char *text, int scaletext);

Description

Draw text at position iP that faces the camera with vector inputs. Use this function only from within a dynamic callback. The components of iOff are in character units along Right and Up vectors - use this to displace labels in screen coordinates. If scaletext is true (non-zero), then text further from the camera will be made larger so that labels are equally legible for all distances.

NOTES

  • This function uses the S2PLOT attributes for character height (size) and colour. The z component of ioff is ignored.
  • If your text does does not appear, try setting the x and y values of ioff to something small, e.g ioff.x = ioff.y = 0.01.

See Also

ds2bb Draw a (dynamic) billboard: a textured facet that always faces the camera
ds2vbb Draw a (dynamic) billboard: a textured facet that always faces the camera - vector input
ds2tb Draw text that always faces the camera
s2sci Set the pen colour by index.
s2sch Set the character height in "arbitrary" units.
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 <math.h>
#include <time.h>
#include "s2plot.h"

XYZ *xyz;				/* Global array - text position */
int N;					/* Number of text labels */

void cb(double *t, int *kc)
/* A dynamic callback */
{
   int i;				/* Loop variable */
   XYZ ioff = { 0.01, 0.01, 0.0 };	/* Small offsets - must be non-zero */
					/*  z offset is ignored */
   
   s2sch(0.2);				/* Set the text height */
   for (i=0;i<N;i++) {			/* Draw the billboard labels */
      ds2vtb(xyz[i], ioff, "S2PLOT", 1);
   }
}


int main(int argc, char *argv[])
{
   int i;					/* Loop variable */
   srand48((long)time(NULL));			/* Seed random numbers */

   s2opend("/S2MONO",argc,argv);		/* Open the display */
   s2swin(-1.5,1.5, -1.5,1.5, -1.5,1.5);
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw coord box */

   N = 20;					/* Number of labels to draw */
   xyz = (XYZ *)calloc(N, sizeof(XYZ));

   for (i=0;i<N;i++) {			/* Create N random (x,y,z) values */
      xyz[i].x = drand48()*2.0 - 1.0;	/* Create N random (x,y,z) values */
      xyz[i].y = drand48()*2.0 - 1.0;
      xyz[i].z = drand48()*2.0 - 1.0;
   }
 
   cs2scb(cb);				/* Install a dynamic callback */

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

   return 1;
}

Back to S2PLOT function list.


Personal tools