Rev | Line | |
---|
[37] | 1 | function 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 | |
---|
| 5 | n = 40; % resolution |
---|
| 6 | radians = [0:(2*pi)/(n-1):2*pi]; |
---|
| 7 | unitC = [sin(radians); cos(radians)]; |
---|
| 8 | |
---|
| 9 | % extend r if necessary |
---|
| 10 | if length(r) < cols(x) |
---|
| 11 | r = [r repmat(r(length(r)), 1, cols(x)-length(r))]; |
---|
| 12 | end |
---|
| 13 | |
---|
| 14 | h = []; |
---|
| 15 | % hold is needed for fill() |
---|
| 16 | held = ishold; |
---|
| 17 | hold on |
---|
| 18 | for 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 |
---|
| 25 | end |
---|
| 26 | if ~held |
---|
| 27 | hold off |
---|
| 28 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.