% graphics
% session 3
clear all; clf;





p1=linspace(0.1,10,10);
p2=linspace(0.1,10,10);
[P1,P2]=meshgrid(p1,p2);

x=linspace(-10,10,100);

P1=P1(:);P2=P2(:);
n=length(P1);
subplot(1,2,1);
for ind=1:n;
    h=plot(P1(ind),P2(ind),'k.');

    
    st=['subplot(1,2,2);title(''' num2str(P1(ind)) ' ' num2str(P2(ind)) ''')']

    set(h,'buttondownfcn',st);

    hold on
end



break



% parameterization and zooming

th=linspace(0,2*pi,70);
r=1+0.2*cos(6*th);
x=r.*cos(th);
y=r.*sin(th);
plot(x,y,'k');

nc=100;

coco=jet(nc);

for ind=1:nc
    r=randn(1,1).^2/5;
    plot(x*r+randn(1,1),y*r+randn(1,1),'color',coco(ind,:),'linewidth',2);
hold on
end

sched=[
 -3     4    -3     3
1.3690    2.1253    1.5584    2.2909
   -1.3048   -0.5484   -0.4866    0.2459
   -2.6540    1.4655   -2.6961    0.9195
 -3     4    -3     3];

ni=100;
tvec=linspace(0,1,ni);
tveco=linspace(0,1,size(sched,1));

meth='spline';
g=[interp1(tveco,sched(:,1),tvec,meth)', ...
   interp1(tveco,sched(:,2),tvec,meth)', ...
   interp1(tveco,sched(:,3),tvec,meth)', ...
   interp1(tveco,sched(:,4),tvec,meth)']
    


for ind=1:ni;
    axis(g(ind,:));
    
    filename=['mov' num2str(ind)];
    disp(['printing ' filename]);tic
    print('-djpeg',filename);
    toc
    drawnow;
end



break

%coco=jet(200);
load colo
coco=f;

n=100;
x=linspace(-10,10,n);
y=linspace(-10,10,n);
[X,Y]=meshgrid(x,y);

tvec=linspace(0,4*pi,400);
nt=length(tvec);

for ind=1:nt
t=tvec(ind);
    f=sin(2*X-t).*exp((-X.^2-Y.^2)/10);
surf(X,Y,f);
shading interp
colormap(coco);



zlim([-1,1]);
caxis([-1,1]);
%view(2)
camlight
lighting gouraud
drawnow

end











break




for tre=1:100

n=200;
x=linspace(-10,10,n);

tvec=linspace(0,4*pi,200);
nt=length(tvec);

lwvec=ceil(linspace(1,20,nt));

coco=jet(nt);

for ind=1:nt
    t=tvec(ind);
f=sin(2*x-t).*exp(-x.^2/10);


c=coco(ind,:);
lw=lwvec(ind);
plot(x,f,'color',c,'linewidth',lw);


% text on the image
sel=2:n-1;
l=find(f(sel)>f(sel+1)&f(sel)>f(sel-1))+1;

for gre=1:length(l);
    loc=l(gre);
    xx=x(loc);
    ff=f(loc);
    val=sprintf('%0.2g',ff); 
    text(xx,ff+0.05,val,'fontsize',20,'color',c);
    hold on
end
hold off

ylim([-1,1.2]);
drawnow


end
end


