Function:ss2ftt

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:24, 27 January 2009
S2plot admin (Talk | contribs)

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

Line 15: Line 15:
== See Also == == See Also ==
<table> <table>
 +<tr><td>[[Function:ss2lt | ss2lt ]]</td><td>Load a texture for future (generally repeated) use. </td></tr>
 +<tr><td>[[Function:ss2ltt | ss2ltt ]]</td><td>Create a texture with LATEX commands.. </td></tr>
</table> </table>

Current revision

ss2ftt

Use a named freetype font to create a texture map.

Prototype

unsigned int ss2ftt(char *fontfilename, char *text, int fontsizepx, int border);

Description

Load a named freetype font, where fontfilename includes the full pathname to the font, to generate a texture map from the input text. Argument fontsizepx controls the font size, and an optional border can be drawn around the text using border > 0.

This function is only available if the S2FREETYPE environment variable has been set to 'yes'.

See Also

ss2lt Load a texture for future (generally repeated) use.
ss2ltt Create a texture with LATEX commands..

Code Example

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

unsigned int tid;

void cb(double *t, int *kc)
{
   XYZ xyz = {0.0, 0.3, 0.4};                           /* Location */
   float isize = 0.02;                                  /* Texture scale */
   XYZ str = { 0.0, 0.0, 0.0};                          /* No stretch */
   COLOUR col = { 1.0, 1.0, 0.0 };                      /* Yellow */
   float alpha = 0.9;                                   /* Alpha channel */
   char trans = 's';                                    /* Transparency */

   ds2vbb(xyz, str, isize, col, tid, alpha, trans);     /* Draw the billboard */
}

int main(int argc, char *argv[])
{
   s2opend("/?",argc,argv);                     /* Open the display */
   s2svp(-1.0,1.0, -1.0,1.0, -1.0,1.0);         /* Set the viewport coords */
   s2swin(-1.0,1.0, -1.0,1.0, -1.0,1.0);        /* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw a bounding box */

   char font[64];                               /* Allocate font name string */

   sprintf(font,"/Library/Fonts/Arial Black");  /* Path to font */
                        /* NOTE: This depends on your local system config */

   tid = ss2ftt(font,"s2plot",32,4);          /* Create the texture */

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

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

   return 1;
}

Back to S2PLOT function list.


Personal tools