Overlapping coloured circles - RGB circles
Show older comments
Hi!
I want to overlap three coloured circles, red, green, blue, in order to form the RGB palette, like below:

So far, i have the following code and result
k = 0 : 0.001 : 2*pi;
x = cos(k)+2.3; y = sin(k)+2;
z = cos(k)+3; w = sin(k)+1;
t = cos(k)+1.5; u = sin(k)+1;
fill(x,y, 'r', EdgeColor='none'),;
hold on
fill(z,w, 'b', EdgeColor='none');
fill(t,u, 'g', EdgeColor='none');
grid off

But I can't make the properly overlap and make them change the colours like above. Any sugestions, please?
Thank you!
Accepted Answer
More Answers (1)
This creates an image:
sz = [512 512]; % image size
cim = sz.*[0.46 0.5]; % [y x] center of image
r = mean(sz)/4; % radius of circle
Pth = [90 210 330]; % position angle
Pr = r*2/3; % position radius
% calculate circle locations
cx = Pr*cosd(Pth) + cim(2);
cy = sz(1)-(Pr*sind(Pth) + cim(1));
% draw circles in an RGB image
outpict = zeros(sz);
for k = 1:numel(Pth)
outpict(:,:,k) = drawcircle(sz,[cy(k) cx(k)],r);
end
% show the result
imshow(outpict)
% draw circle with smooth edges
function circ = drawcircle(sz,c,r)
xx = 1:sz(2);
yy = (1:sz(1)).';
circ = sqrt((xx-c(2)).^2 + (yy-c(1)).^2);
circ = min(max((r-circ)/2,0),1);
end
I'm sure there are plenty of other ways.
1 Comment
Carmen Chira
on 27 Mar 2022
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
