function candle
%CANDLE Das ultimative 1.Advent m-File ;-)

%Erweiterung für 2. Advent (schottisch ;-)

xs = -5;

x=-1:.1:12;
y=erf(x-2)-erf((x-6)./4);     %Silouette der Flamme
[a b c]=cylinder(y,50);       %Flamme
[d e f]=cylinder(.4);         %Kerze
[g h i]=cylinder([.4,0]);     %Boden & Deckel
top=surf(g,h,i/7);
hold on
i(:,:)=0;                     %spitzen deckel für boden abflachen
bottom=surf(g,h,i-1);
candle=surf(e,d,f-1);
flame=surf(b/10,a/10,c,'edgecolor','none','facecolor','interp');
set([top,bottom,candle],'edgecolor','none','facecolor',[1 0 0]);
tx = [xs-1,xs-1,xs/2,1,1];
ty = [2,-2,-2,-0.9,2];
tz = -ones(size(tx));
table = fill3(tx,ty,tz,'w');
set(table,'FaceColor',[0,0.1,0.2],'Edgecolor',[0.4,0.2,0]);
mz = 2.5*[0,0,1,1]-1;
my = 4*[0,1,1,0]-2;
mx = xs/2*ones(size(mz));
mirror = fill3(mx,my,mz,'w');
set(mirror,'FaceColor',[1,1,1],'Edgecolor',[0,0.4,0.8],'Facealpha',0.1);
base = [top,bottom,candle];
base2 = copyobj(base,gca);
for n=1:size(base2,1),
    set(base2(n),'XData',xs-get(base2(n),'XData'));
end;
colormap(hot)
l=light('Position',[0 0 0.3],'Style','local','color',[1 1 0]); %Licht isz in der flamme
l2=light('Position',[xs 0 0.3],'Style','local','color',[1 1 0]); %Licht isz in der flamme
axis equal off tight
set(gcf,'color','k')
set(gca,'Position',[0,0,1.1,1.1]);
set(gca,'projection','perspective');
view(-70,10)
lighting gouraud
set(flame,'FaceLighting','none') %flamme nicht beleuchten
set(flame,'facealpha',.6)        %und transparent
xdat=get(flame,'xdata');         %daten der flamme auslesen
ydat=get(flame,'ydata');
zdat=get(flame,'zdata');
for j=1:100                      %und zufällig in allen 3 dim stecken/stauchen
    f=(rand(3,1)*0.2)-.1;
    set(l,'position',[0+f(1) 0+f(2) 0.3+f(3)]) %positon des lichtes mit verändern
    set(l2,'position',[xs-f(1) 0+f(2) 0.3+f(3)]) %positon des lichtes mit verändern
    set(flame,'XData',xdat*(1+f(1)),'yData',ydat*(1+f(2)),'zData',zdat*(1+f(3)))
    if exist('flame2'), delete(flame2); end
    flame2=copyobj(flame,gca);
    set(flame2,'XData',xs-get(flame2,'XData'));
    pause(0.1)
end

return