]> Creatis software - CreaPhase.git/blob - octave_packages/geometry-1.5.0/io/@svg/plot.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / geometry-1.5.0 / io / @svg / plot.m
1 ## Copyright (C) 2011 CarnĂ« Draug <carandraug+dev@gmail.com>
2 ## Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
3 ##
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 3 of the License, or
7 ## (at your option) any later version.
8 ##
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details.
13 ##
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
16
17 %% -*- texinfo -*-
18 %% @deftypefn {Function File} {@var{h} = } plot ()
19 %% Plots and SVG object.
20 %%
21 %% @end deftypefn
22
23 function h = plot(obj, varargin)
24
25   % Get path ids
26   ids = fieldnames(obj.Path);
27   npath = numel(ids);
28
29   t = linspace (0, 1, 64);
30   
31   args={};
32   if !isempty (varargin)
33     args = varargin;
34   end
35   for i = 1:npath
36     x = []; y = [];
37     data = obj.Path.(ids(i)).data;
38
39     for j = 1:numel(data)
40       x = cat (2, x, polyval (data{j}(1,:),t));
41       y = cat (2, y, polyval (data{j}(2,:),t));
42     end
43
44     h = plot(x,y,args{:});
45     if i == 1
46       hold on
47     end
48  end
49  hold off
50  axis tight
51  axis equal
52 endfunction
53