comparison doc/interpreter/geometryimages.m @ 20351:d8992a16643c

doc: Clean up m-files which generate images for Manual. * geometryimages.m, interpimages.m, plotimages.m, sparseimages.m, splineimages.m: Use the same style throughout the mi-files. Obey Octave coding conventions.
author Rik <rik@octave.org>
date Thu, 09 Jul 2015 21:38:57 -0700
parents c3c1fb44f9b5
children b439ccc9a162
comparison
equal deleted inserted replaced
20350:b9d4ccf4291c 20351:d8992a16643c
18 18
19 function geometryimages (d, nm, typ) 19 function geometryimages (d, nm, typ)
20 graphics_toolkit ("gnuplot"); 20 graphics_toolkit ("gnuplot");
21 set_print_size (); 21 set_print_size ();
22 hide_output (); 22 hide_output ();
23 outfile = fullfile (d, strcat (nm, ".", typ)); 23 outfile = fullfile (d, [nm "." typ]);
24 if (strcmp (typ, "png")) 24 if (strcmp (typ, "png"))
25 set (0, "defaulttextfontname", "*"); 25 set (0, "defaulttextfontname", "*");
26 endif 26 endif
27 if (strcmp (typ, "eps")) 27 if (strcmp (typ, "eps"))
28 d_typ = "-depsc2"; 28 d_typ = "-depsc2";
48 [r, c] = tri2circ (tri(end,:), x, y); 48 [r, c] = tri2circ (tri(end,:), x, y);
49 pc = [-1:0.01:1]; 49 pc = [-1:0.01:1];
50 xc = r * sin (pi*pc) + c(1); 50 xc = r * sin (pi*pc) + c(1);
51 yc = r * cos (pi*pc) + c(2); 51 yc = r * cos (pi*pc) + c(2);
52 plot (xc, yc, "g-", "LineWidth", 3); 52 plot (xc, yc, "g-", "LineWidth", 3);
53 axis([0, 1, 0, 1]); 53 axis ([0, 1, 0, 1]);
54 legend ("Delaunay Triangulation", "Voronoi Diagram"); 54 legend ("Delaunay Triangulation", "Voronoi Diagram");
55 print (outfile, d_typ); 55 print (outfile, d_typ);
56 elseif (strcmp (nm, "triplot")) 56 elseif (strcmp (nm, "triplot"))
57 rand ("state", 2) 57 rand ("state", 2)
58 x = rand (20, 1); 58 x = rand (20, 1);
111 yc = - (xc - (x(2) + x(3))./2) ./ m(end) + (y(2) + y(3)) / 2; 111 yc = - (xc - (x(2) + x(3))./2) ./ m(end) + (y(2) + y(3)) / 2;
112 c = [xc, yc]; 112 c = [xc, yc];
113 r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2); 113 r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2);
114 endfunction 114 endfunction
115 115
116 function sombreroimage (nm, typ, d_typ)
117 if (strcmp (typ, "txt"))
118 fid = fopen ([nm ".txt"], "wt");
119 fputs (fid, "+-----------------------------+\n");
120 fputs (fid, "| Image unavailable because |\n");
121 fputs (fid, "| of a missing QHULL library. |\n");
122 fputs (fid, "+-----------------------------+\n");
123 fclose (fid);
124 return;
125 else
126 hide_output ();
127 [x, y, z] = sombrero ();
128 unwind_protect
129 mesh (x, y, z);
130 title ("Sorry, graphics not available because Octave was\\ncompiled without the QHULL library.");
131 unwind_protect_cleanup
132 print (outfile, d_typ);
133 hide_output ();
134 end_unwind_protect
135 endif
136 endfunction
137
116 function set_print_size () 138 function set_print_size ()
117 image_size = [5.0, 3.5]; # in inches, 16:9 format 139 image_size = [5.0, 3.5]; # in inches, 16:9 format
118 border = 0; # For postscript use 50/72 140 border = 0; # For postscript use 50/72
119 set (0, "defaultfigurepapertype", "<custom>"); 141 set (0, "defaultfigurepapertype", "<custom>");
120 set (0, "defaultfigurepaperorientation", "landscape"); 142 set (0, "defaultfigurepaperorientation", "landscape");
124 146
125 ## Use this function before plotting commands and after every call to 147 ## Use this function before plotting commands and after every call to
126 ## print since print() resets output to stdout (unfortunately, gnpulot 148 ## print since print() resets output to stdout (unfortunately, gnpulot
127 ## can't pop output as it can the terminal type). 149 ## can't pop output as it can the terminal type).
128 function hide_output () 150 function hide_output ()
129 f = figure (1); 151 hf = figure (1);
130 set (f, "visible", "off"); 152 set (hf, "visible", "off");
131 endfunction
132
133 function sombreroimage (nm, typ, d_typ)
134 if (strcmp (typ, "txt"))
135 fid = fopen (sprintf ("%s.txt", nm), "wt");
136 fputs (fid, "+-----------------------------+\n");
137 fputs (fid, "| Image unavailable because |\n");
138 fputs (fid, "| of a missing QHULL library. |\n");
139 fputs (fid, "+-----------------------------+\n");
140 fclose (fid);
141 return;
142 else ## if (!strcmp (typ, "txt"))
143
144 hide_output ();
145
146 [x, y, z] = sombrero ();
147 unwind_protect
148 mesh (x, y, z);
149 title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library.");
150 unwind_protect_cleanup
151 print (outfile, d_typ);
152 hide_output ();
153 end_unwind_protect
154 endif
155 endfunction 153 endfunction
156 154
157 ## generate something for the texinfo @image command to process 155 ## generate something for the texinfo @image command to process
158 function image_as_txt (d, nm) 156 function image_as_txt (d, nm)
159 fid = fopen (fullfile (d, strcat (nm, ".txt")), "wt"); 157 fid = fopen (fullfile (d, [nm ".txt"]), "wt");
160 fputs (fid, "\n"); 158 fputs (fid, "\n");
161 fputs (fid, "+---------------------------------+\n"); 159 fputs (fid, "+---------------------------------+\n");
162 fputs (fid, "| Image unavailable in text mode. |\n"); 160 fputs (fid, "| Image unavailable in text mode. |\n");
163 fputs (fid, "+---------------------------------+\n"); 161 fputs (fid, "+---------------------------------+\n");
164 fclose (fid); 162 fclose (fid);