Although not the earliest to appear here in the UK, Daffodils are the flowers that, for me at least, scream "Spring has sprung." The brief but glorious Daffodil season is coming to an end in my area of the world so I was delighted by the following piece of MATLAB code written by MathWorker Eric Ludlam which allows me to extend the season for a little while longer.
pc = '#faca00'; % petal color
sc = '#97b580'; % stem color
np = 6; % number of petals.
tr = .23; % Radius of trumpet
nruf = 10; % number of trumpet ruffles
sruf = .03; % size of trumpet ruffles
sr = .05; % radius of the stem
n = np*50+1; % Theta resolution
nr = 20; % Radus resolution
PR = r .* ((1-abs(1-mod(theta*np, 2)))/2+.5);
PZ = r.^3*.05+hypot(PX,PY)*.2;
% Face our flower sideways by swapping Y&Z
surf(PX,PZ,PY,[],'FaceColor',pc,'EdgeColor','none');
ruffle = ((cospi(theta*nruf)+2)*sruf).*(linspace(0,1,nr)'.^5);
ruffle2 = ((cospi(theta*nruf*3)+2)*sruf/3).*(linspace(0,1,nr)'.^9);
TR = tr*flute + ruffle + ruffle2;
surface(TR.*cospi(theta),r*tr*3.2,TR.*sinpi(theta),'FaceColor',pc,'EdgeColor','none');
surface(SR.*cospi(theta),SR.*sinpi(theta)-sr,r*-2.*ones(1,n),'FaceColor',sc,'EdgeColor','none');
%% Configure Axes & Lighting
set(gca,'YDir','reverse','Projection','perspective','Visible','off','DataAspectRatio',[1 1 1])
light('Position',[.5 .5 2],'Color','w');
material([.8 .9 .2 2 .4])
Perhaps try playing around with the code a little to come up with some variations.
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.