source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/graphics/draw_circle.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 665 bytes
Line 
1function h = draw_circle(x, r, outline_color, fill_color)
2% draw filled circles at centers x with radii r.
3% x is a matrix of columns.  r is a row vector.
4
5n = 40;                                 % resolution
6radians = [0:(2*pi)/(n-1):2*pi];
7unitC = [sin(radians); cos(radians)];
8
9% extend r if necessary
10if length(r) < cols(x)
11  r = [r repmat(r(length(r)), 1, cols(x)-length(r))];
12end
13
14h = [];
15% hold is needed for fill()
16held = ishold;
17hold on
18for i=1:cols(x)
19  y = unitC*r(i) + repmat(x(:, i), 1, n);
20  if nargin < 4
21    h = [h line(y(1,:), y(2,:), 'Color', outline_color)];
22  else
23    h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)];
24  end
25end
26if ~held
27  hold off
28end
Note: See TracBrowser for help on using the repository browser.