Function:s2latexture

From S2PLOT

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

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

Line 41: Line 41:
id = s2latexture(latexcmd, &aspect); /* Create latex texture */ id = s2latexture(latexcmd, &aspect); /* Create latex texture */
/* Must have S2PLOT_LATEXBIN environment variable correctly set */ /* Must have S2PLOT_LATEXBIN environment variable correctly set */
 +
 + aspect = 1.0/aspect;
pos[0].x = -1.0; pos[0].y = +aspect; pos[0].z = 0.0; pos[0].x = -1.0; pos[0].y = +aspect; pos[0].z = 0.0;

Current revision

s2latexture

Create a texture with LATEX commands.

Prototype

int s2latexture(char *latexcmd, float *aspect);

Description

Create a texture with LaTeX commands contained in the string latexcmd. The return value is the texture handle (as used by eg. ns2vf4xt etc). The x:y aspect ratio of the texture map is returned in aspect.

This function assumes that LaTeX is installed on your system in the location indicated by the environment variable S2PLOT_LATEXBIN.

See Also

ss2lt Load a texture for future (generally repeated) use.


Code Example

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

int main(int argc, char *argv[])
{
   char *latexcmd = "$f(x) = \\Sigma^{\\infty}_{i=0} a_i \\sin(2\\pi x)$";
   XYZ pos[4];					/* Vertices for texture */
   COLOUR col = { 1.0, 1.0, 1.0 };		/* Polygon colour */
   float aspect;				/* Aspect ratio */
   int id;					/* Texture id */

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

   id = s2latexture(latexcmd, &aspect);		/* Create latex texture */
	/* Must have S2PLOT_LATEXBIN environment variable correctly set */

   aspect = 1.0/aspect;

   pos[0].x = -1.0; pos[0].y = +aspect; pos[0].z = 0.0;
   pos[1].x = +1.0; pos[1].y = +aspect; pos[1].z = 0.0;
   pos[2].x = +1.0; pos[2].y = -aspect; pos[2].z = 0.0;
   pos[3].x = -1.0; pos[3].y = -aspect; pos[3].z = 0.0;

   ns2vf4x(pos, col, id, 1.0, 'o');		/* Draw the texture */

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

Back to S2PLOT function list.


Personal tools