]> Creatis software - CreaPhase.git/blob - octave_packages/vrml-1.0.13/vrml_text.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / vrml-1.0.13 / vrml_text.m
1 ## Copyright (C) 2002 Etienne Grossmann <etienne@egdn.net>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ##       s = vrml_text(t,...) 
17 ##
18 ## Makes vrml Shape node representing string t
19 ## 
20 ## Options : 
21 ##
22 ## "col" , col             : default = [ 0.3 0.4 0.9 ]
23 ## "size" , size           : default = 1.0
24 ## "family", family        : default = "SERIF". 
25 ##                           (could also be : "TYPEWRITER", "SANS")
26 ## "style", style          : default = "PLAIN". 
27 ##                           (could also be : "BOLD", "ITALIC", "BOLDITALIC")
28 ## "justify", justify      : default = "MIDDLE"
29 ##                           (could also be "FIRST", "BEGIN", "END")
30
31 function s = vrml_text(t,varargin)
32
33 col     = [0.3,0.4,0.9] ;
34 size    = 1.0 ;
35 family  = "SERIF" ;
36 justify = "MIDDLE" ;
37 style   = "PLAIN" ;
38 verbose = 0 ;
39
40 filename = "vrml_text" ;
41 if nargin > 1
42   op1 = " col size family justify style " ;
43   op0 = " verbose " ;
44
45   df = tars (col, size, family, justify, style, verbose);
46
47   s = read_options (varargin, "op1",op1,"op0",op0, "default",df);
48   col=       s.col;
49   size=      s.size;
50   family=    s.family;
51   justify=   s.justify;
52   style=     s.style;
53   verbose=   s.verbose;
54 end
55 s = sprintf (["Shape {\n",\
56               "  appearance Appearance {\n",\
57               "    material Material {\n",\
58               "      diffuseColor  %8.3f %8.3f %8.3f\n",\
59               "      emissiveColor %8.3f %8.3f %8.3f\n",\
60               "    }\n",\
61               "  }\n",\
62               "  geometry Text {\n",\
63               "    string \"%s\"\n"\
64               "    fontStyle FontStyle {\n",\
65               "      family  \"%s\"\n",\
66               "      justify \"%s\"\n",\
67               "      style   \"%s\"\n",\
68               "      size     %-8.3f\n",\
69               "    }\n",\
70               "  }\n",\
71               "}\n",\
72               ],\
73              col,\
74              col,\
75              t,\
76              family,\
77              justify,\
78              style,\
79              size\
80              );
81
82 endfunction
83