print.m: SVG ans size specification for PNG and SVG

View: New views
2 Messages — Rating Filter:   Alert me  

print.m: SVG ans size specification for PNG and SVG

by Francesco Potorti`-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This patch, which is alternative to the previously posted one, adds the
SVG type to the capabilities of print.m and additionally allows for a
-Sxsize,ysize option for PNG and SVG terminals.

--- /home/pot/math/octavelib/utils/myprint.m~ 2007-09-21 12:48:05.000000000 +0200
+++ /home/pot/math/octavelib/utils/myprint.m 2007-09-21 13:30:55.000000000 +0200
@@ -69,20 +69,22 @@
 ##   @item cdr
 ##   @itemx corel
 ##     CorelDraw
-##   @item hpgl
-##     HP plotter language
-##   @item fig
-##     XFig
 ##   @item dxf
 ##     AutoCAD
+##   @item emf
+##     Microsoft Enhanced Metafile
+##   @item fig
+##     XFig
+##   @item hpgl
+##     HP plotter language
 ##   @item mf
 ##     Metafont
 ##   @item png
 ##     Portable network graphics
 ##   @item pbm
 ##     PBMplus
-##   @item emf
-##     Microsoft Enhanced Metafile
+##   @item svg
+##     Scalable vector graphics
 ##   @end table
 ##
 ##   Other devices are supported by "convert" from ImageMagick.  Type
@@ -91,6 +93,9 @@
 ##   If the device is omitted, it is inferred from the file extension,
 ##   or if there is no filename it is sent to the printer as postscript.
 ##
+## @itemx -S@@var{xsize},@var{ysize}
+##   Plot size in points for PNG and SVG.
+##
 ## @item -F@var{fontname}
 ## @itemx -F@var{fontname}:@var{size}
 ## @itemx -F:@var{size}
@@ -116,6 +121,7 @@ function print (varargin)
   force_solid = 0; # 0=default, -1=dashed, +1=solid
   fontsize = "";
   font = "";
+  size = "";
   name = "";
   devopt = "";
   printer = "";
@@ -147,6 +153,8 @@ function print (varargin)
  else
   font = arg(3:length(arg));
  endif
+      elseif (length (arg) > 2 && arg(1:2) == "-S")
+ size = arg(3:length(arg));
       elseif (length (arg) >= 1 && arg(1) == "-")
  error ("print: unknown option `%s'", arg);
       elseif (length (arg) > 0)
@@ -191,7 +199,7 @@ function print (varargin)
   endif
 
   ## check if we have to use convert
-  dev_list = {"aifm", "corel", "fig", "png", "pbm", "dxf", "mf", ...
+  dev_list = {"aifm", "corel", "fig", "png", "pbm", "dxf", "mf", "svg", ...
       "hpgl", "ps", "ps2", "psc", "psc2", "eps", "eps2", ...
       "epsc", "epsc2", "emf", "pstex", "pslatex", ...
       "epslatex", "epslatexstandalone"};
@@ -325,11 +333,25 @@ function print (varargin)
     ##eval (sprintf ("__gnuplot_set__ term %s mono medium", dev));
     ##endif
 
-    new_terminal = "png large";
+    if (isempty (size))
+      options = " large";
+    else
+      options = strcat (" size ", size);
+    endif
+    new_terminal = strcat ("png", options);
 
   elseif (strcmp (dev, "dxf") || strcmp (dev, "mf") || strcmp (dev, "hpgl"))
     ## AutoCad DXF, METAFONT, HPGL
     new_terminal = dev;
+
+  elseif (strcmp (dev, "svg"))
+    ## SVG
+    options = "";
+    if (! isempty (size))
+      options = strcat (" size ", size);
+    endif
+    new_terminal = strcat ("svg", options);
+
   endif
 
   drawnow (new_terminal, name);

--
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: Potorti@...
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key
_______________________________________________
Octave-sources mailing list
Octave-sources@...
https://www.cae.wisc.edu/mailman/listinfo/octave-sources

print.m: SVG ans size specification for PNG and SVG

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 21-Sep-2007, Francesco Potorti` wrote:

| This patch, which is alternative to the previously posted one, adds the
| SVG type to the capabilities of print.m and additionally allows for a
| -Sxsize,ysize option for PNG and SVG terminals.

I applied this patch.

BTW, I would have missed this change if you had not mentioned it
again.  In the future, it would be best to send changes for existing
code to the bug@... list.

Thanks,

jwe
_______________________________________________
Octave-sources mailing list
Octave-sources@...
https://www.cae.wisc.edu/mailman/listinfo/octave-sources
LightInTheBox - Buy quality products at wholesale price