Function:ss2ltt

From S2PLOT

Jump to: navigation, search

ss2ltt

Create a texture with LATEX commands.

Prototype

unsigned int ss2ltt(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.
ss2ftt Use a named freetype font to create a texture map.


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 */
   unsigned 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 = ss2ltt(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