• Remix
  • Share
  • New Entry

on 1 Dec 2023
  • 13
  • 35
  • 0
  • 3
  • 1628
drawframe(1);
Write your drawframe function below
function drawframe(f)
clf
% Not a believer in the singularity. But it's an interesting concept for
% exploration in story & myth.
eyo = [zeros(1,30),linspace(0,1,8).^.3,ones(1,13)];
HP=[4;.45;4;.3;.52;1.32;2.2;-1;.5-eyo(f);.75;20];
fcs = [linspace(0,1,35).^3*400+10, ones(1,13)*410];
[x,y,z]=face(round(fcs(f)),HP);
% Rotation
a=@(x,y,r)x*cos(r)-y*sin(r);
b=@(x,y,r)x*sin(r)+y*cos(r);
% Plot
r=(-65)*pi/180;
S=@(x,y,z)surf(x,y,z,'EdgeC','none','FaceC',[1,1,1],'DiffuseS',.2,'SpecularE',1,'SpecularS',1,'AmbientS', 0.0);
S(a(x,y,r),z,b(x,y,r));
axis equal off
set(gcf,'color','k');
% Light
light('pos',[.37,-1,1.4]);
view([-160, -18]);
camtarget([0,0,0]);
camva(6);
end
function [x,y,z]=face(n,P)
% Start with a basic sphere
[x,y,z]=sphere(n);
% General distortions to make it more face like
z=erf(z*P(10));
x(y<0)= x(y<0)-abs(y(y<0)).^P(1)*P(2);
z(y<0)= z(y<0).*(1-.5*y(y<0).^P(3));
z(y>0)=z(y>0).*(1-.1*y(y>0).^2);
x(x<0)= erf(0.6*x(x<0))/0.6;
x(x>0)=x(x>0)*.9;
y(y>0)=y(y>0)*.9;
y=y+P(4);
z(y>0)=z(y>0).*exp(-x(y>0).^2/3).^y(y>0);
y=y-.3;
x=x+.6;
x(x>0)=x(x>0)*.9;
x=x-.6;
er=@(x,o,s).5-erf(-s*x+o).*erf(s*x+o)/2;
c=y(x<0);
c=1-exp(-(c+(exp(c*3)-0.4)).^2*3).*(.7*er(z(x<0),.8,10)+.3).*.1;
x(x<0)=c.*x(x<0);
fc=@(x)exp(-(-x+(exp(-x*9)-.6)).^2*2);
fc2=@(x)exp(-(-x+(exp(-x*2)-.6)).^2*2);
% Adding nose & lips
x(x<0)=((1-1*er(z(x<0),2,15)).*(fc(y(x<0)*1+P(5))*.15)+1).*x(x<0);
x(x<0)=((1-1*er(z(x<0),.7,8)).*(fc(y(x<0)*2+P(6))*.08)+1).*x(x<0);
x(x<0)=((.7-.7*er(z(x<0),0,8.5)).*(-fc(-y(x<0)*P(7)-1.71)*.06)+1).*x(x<0);
x=x+.5;
x(x>0)=x(x>0).*(1-.35*fc2((y(x>0)+.95)/1.4));
x=x-.5;
z=z.*(((x-.2).^2+(y+.4).^2).^.4*.2+.8);
x=x+.5;
% Adding eyes
[x,y,z]=ey(x,y,z,P,1);
[x,y,z]=ey(x,y,z,P,-1);
end
function [x,y,z]=ey(x,y,z,P,s)
b=@(x)tanh(exp(-4*abs(x).^2.5));
xt=(z(x<0)+s*0.33)*5;
yt=(y(x<0)+.145)*7;
ofs=max(b2(yt+P(8)*.2*xt.^2,P(9),P(11)).*b(sqrt(xt.^2+yt.^2)), b(sqrt(1.5*xt.^2+yt.^2))*.7);
x(x<0)=x(x<0)-ofs/20;
end
% Bump function with edge for eyes
function ot=b2(x,of,s)
x2=(erf((x+of)*s)/1.5+.5);
ot=x2+exp(-(x+(of-.1)).^2*10)/4;
end
Animation
Remix Tree