当前位置: 首页 > news >正文

做网站中山外贸网站怎么做

做网站中山,外贸网站怎么做,杭州西湖区抖音seo哪里找,淘宝上做网站 源代码怎么给你嘿真的又是很久没见了#xff0c;最近确实有点非常很特别小忙#xff0c;今天带来一下MATHWORKS官方举办的迷你黑客大赛第三期(MATLAB Flipbook Mini Hack)的最新进展#xff01;#xff01;目前比赛已经刚好进行了一周#xff0c;前两届都要求提交280个字符内的代码来生成…嘿真的又是很久没见了最近确实有点非常很特别小忙今天带来一下MATHWORKS官方举办的迷你黑客大赛第三期(MATLAB Flipbook Mini Hack)的最新进展目前比赛已经刚好进行了一周前两届都要求提交280个字符内的代码来生成图片但是这一届要求提交2000个字符内的代码来生成动画字符限制一放开大家就开始有种各显神通的意思仅仅一周就贡献了接近200个优质作品 本次比赛要求提交名为drawframe(f)的函数代码生成长达2s48帧的动态图动图生成是依靠如下代码来做到的 function contestAnimator()animFilename animation.gif; % Output file namefirstFrame true;framesPerSecond 24;delayTime 1/framesPerSecond;% Create the giffor frame 1:48drawframe(frame)fig gcf(); fig.Units pixels;fig.Position(3:4) [300,300];im getframe(fig);[A,map] rgb2ind(im.cdata,256);if firstFramefirstFrame false;imwrite(A,map,animFilename, LoopCountInf, DelayTimedelayTime);elseimwrite(A,map,animFilename, WriteModeappend, DelayTimedelayTime);endend end闲话少叙一起看作品 作品概览 看过前两期比赛的人应该对Tim大佬有着深刻的印象这期比赛第一周他也贡献了三个优质的作品 Tim / Rolling fog https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13177 function drawframe(nn)% Moon over rolling fog. % Comments below,% Persistent variables - keep you from having to recompute these% variables at each iteration / save computation timepersistent enz ags x d c mx my mn cmpif nn 1 % Everything is precomputed so we dont really need this - undo to% get different clouds each timerng default% Base vector for pixelsx linspace(-1, 1, 240);% Make complex 3D noise spectrum - spectrally shaping using% distance. This is expensive so only do once.blength(x);dx(1:2:end)/2;clength(d);r ifftshift(sqrt((x*2).^2 d.^2 permute(x.^2, [1, 3, 2])));ags linspace(0, 2*pi, 49);enz exp(6i*randn(c, b, b))./max(r.^2.4,2e-5);% Make moon[mx, my] meshgrid(x);rd (mx-0.6).^2 (my0.2).^2;mn 1 - erf(max(rd - 0.3, 0)*3);% Custom colormap for cloudscmp linspace(0, 1, 256).*[1, 1, 1];cmp(:, 1) cmp(:, 1).^1.6;cmp(:, 2) cmp(:, 2).^1.6*0.97;cmp(:, 3) tanh(cmp(:, 3))*1.1;end% Compute current noise realization. Linear phase causes a looping% shift and offset creates the cloud morphing.dt abs(ifftn(exp(1i*(x.*ags(nn)/2 - ags(nn)/2)).*enz));% Tapering the noisedt 5*dt.*(d-d(1)).*permute(erf((x - 0.1)*2)1, [1, 3, 2]);dt dt(:, :, 1:end);% Thresholding for transparencyap dt0.08;% Making it look like clouds / adding glintc_alp cumsum(ap, 3);CLS (1.1 - erf(c_alp/5)).*ap.*dt;ALP ap.*rescale(dt);% Alpha blend across volume[AI, AS] P(ALP, CLS);% Loop spatially / keeps formations in roughly same spot. Turn off to% see a different cloud movement effect.AI circshift(squeeze(AI), [0, -5*nn]);AS circshift(squeeze(AS), [0, -5*nn]);% Web Matlabs 3D rendering is so slow that this fails to execute if% you use surf to blend the images, so lets use the alpha-blender used% to flatten the clouds for the RGB background, moon and cloud layers% Convert clouds to RGB image using custom colormapC round(min(AI*40, 1)*2551);C double(ind2rgb(C, cmp));% Permuter to work with alpha blending function conventionPP (x)permute(x, [3, 2, 1]);% This is a mess, but, it computes the alpha then applies the alpha% blender to each channel and combines to form an image.A PP(cat(3, AS, mn, ones(size(mn)))); IG PP([P(A, PP(cat(3, C(:, :, 1), mn, 0*mn))); P(A, PP(cat(3, C(:, :, 2), mn, 0*mn))); P(A, PP(cat(3, C(:, :, 3), mn*0.9, 0*mn)))]);% Now, show.image(IG); axis equal; camva(5.8);%S.D.G.% Alphablend functionfunction [AIf, ASf] P(ATf, CLSf)ASf ATf(1, :, :);AIf CLSf(1, :, :);% Have alpha, have intensity, compress onto single plane using alpha% blending formulafor nf 2:size(ATf, 1)APf ASf;ASf APf ATf(nf, :, :).*(1-APf);AIf (AIf.*APf CLSf(nf, :, :).*ATf(nf, :, :).*(1-APf))./(eps ASf);endend endTim / Endless tunnel https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12822 % % % Endless Tunnel % % How this works: % - A torus is generated with texture that is periodic at pi/4 intervals % - The camera is moved around a quarter of the torus so that looping has % no discontinuities. % % We are swimming in characters this year so this could be significantly % compressed and more features added! function drawframe(nn) % This enables the same random texture to be created every time rng default; r6; % Torus radius N80; % Texture resolution. Set to higher on your own computer for improvements.% (Has longer rendering times!) Rzeros(N, N*8); % Initial torus radius R(:,N/2:N:end)-.02; % Notches every bit Rconv2(R,[1:4,3:-1:1],same); % Fare the notches RRconv2(randn(size(R))/500,ones(3)/9,same)1; % Add some random noise. Probably doesnt do a whole% lot for N 80. R(end, :)R(1, :); % Match endpoints to prevent a glitch % Make angles for torus (radial and axial) l(x)linspace(0,2*pi,x); ag1l(N); ag2l(N*8); % This will be the tunnel bR.*cos(ag1); zR.*sin(ag1); xb.*cos(ag2)r*cos(ag2); yb.*sin(ag2)r*sin(ag2);; % This will be the algae growing on the pipe R2R*.99; bR2.*cos(ag1); z2R2.*sin(ag1); x2b.*cos(ag2)r*cos(ag2); y2b.*sin(ag2)r*sin(ag2); % This will eventually be the water at the bottom rdlinspace(4, 8, N); xdrd.*cos(ag2); ydrd.*sin(ag2); % Make camera positions aglinspace(0,2*pi,48*4); cpxr*cos(ag); cpyr*sin(ag); cpzzeros(size(cpx))-0.2; % Texture: this will be the water. Making a complex random % function. Noise generated spectrally like this has looping boundaries / % can be tiled, so it is tiled for start/end consistency [xx,yy]meshgrid(linspace(-1,1,N*8),linspace(-1,1,N)); rdsqrt(xx.^2yy.^2); sgnO((randn(N, N*8)1i*randn(N, N*8))./((ifftshift(rd.^2)1e-5))); sgnOifft2(sgnO(:,[1:N,end-N1:end])); sgnO[sgnO,sgnO,sgnO,sgnO]; % This will be the algae on the side. sg(((randn(N,N*8)1i*randn(N, N*8))./((ifftshift(rd.^2)1e-6)))); sgreal(ifft2(sg(:, 1:N*2))); sg[sg,sg,sg,sg]; sgerf(sg*2)1; sg-sg.*(1-erf(sin(ag1)1)); % This will be our phase looper. Since the water phase noise is complex, we % can loop over 2*pi to get a splashing effect agslinspace(0, pi/4, 49); agsags(1:48); clf % Lights seem to accumulate without this... % Algae color clrF permute([0.3, 0.5, 0.3]*0.4, [1, 3, 2]); % Faster if we limit the number of faces generated each frame... this % truncates the rendered portion of the torus to what is visible [~, ci] min(abs(ag2-ag(nn))); rgv (1:N*2) ci; % Update water noise using a phase rotation sgn real(sgnO.*exp(1i*ags(nn)*16)); sgn sgn - mean(sgn(:)); sgn erf(1*sgn/std(sgn(:))); % Truncate sgn sgn(:, rgv); sg sg(:, rgv); idz N*8; % Begin plotting clr (conv2(rand(N, N*8), ones(5)/25, same)*0.30.7).*ones(N, N*8, 3)*0.5; surf(x(:, rgv), y(:, rgv), z(:, rgv), clr(:, rgv, :), SpecularStrength, 1, AmbientStrength, 0); hold on; surf(x2(:, rgv), y2(:, rgv), z2(:, rgv), (rand(size(sgn))*0.20.8).*clrF, FaceAlpha, flat, AlphaData, erf(rescale(1-sg)*20.5)*1, SpecularStrength, 0, AmbientStrength, 0); surf(xd(:, rgv), yd(:, rgv), rand(size(sgn))*0.002 sgn/20-0.8, FaceAlpha, 0.9, AmbientStrength, 0, DiffuseStrength, 0.35, SpecularStrength, 1); % Appearance and camera settings shading interp axis equal camproj(Perspective); camva(50); campos([cpx(nn), cpy(nn), cpz(1)sin(ags(nn)*16)/6 - 0.2]); camtarget([cpx(nn18), cpy(nn18), cpz(nn18)-0.4]); % Headlight: one doesnt seem strong enough camlight; camlight D camlight; D.Color [0.6, 0.8, 1]; % This is inefficient, should just directly set water color in the call to % surf but you can pick a different colormap to alter the water color here cmp copper summer; colormap(cmp/2); caxis([-1, 1]); % S.D.G. endTim / Ring world https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13660 function drawframe(f) % Ring world... persistent H CS S3 U if f1rng(2,v4)% % % % Make the ring % % % %r6; % RadiusN60; % Number of edge-pixels on base unitU8; % Rotating by 1/8 of a circle% Add texture to ring. Make it tech-yRzeros(N,N);R(randi(N^2, 3))1;k1ones(N/2)/10;k2k1;k2(2:end-1,2:end-1)0; % Kernel for glowing lightsRLconv2(R,k2,same); % Glowing lightsRconv2(R,k1,same); % Surface% TilingRrepmat(R,[1,U])1;RLrepmat(RL,[1,U]);% Fix seams. Expendable code.Rs(R,N);RLs(RL,N);RB(R-1)/2;RLRL./RL;% Notch to fit the land in...NHN/2;NWfloor(N/6);R(NH-NW1:NHNW, :)0;% Make our anglesl(x)linspace(0,2*pi,x);ag1l(N);al(N*U);ccos(a);vsin(a);% Ring torusberf(R.*cos(ag1)*5)RB; % Make it square-ishzR.*sin(ag1);xb.*cr*c;yb.*vr*v;% % % % Make the land inside.% Spectral noise shaping... land mass will be a noisy cylinderqlinspace(-1,1,N);rand(8);k()exp(6i*randn(N))./(q.^2q.^22e-4);oo(x)ifft2(x);Brescale(abs(oo(k())))-.3;CSk();Crescale(abs(real(oo(CS.*exp(1i*.10)))))-.5;X(x)max(repmat(x,[1,U]),0);BX(B)/2; % Max makes the waterCX(C); % Clouds% Assemble the cylinder s [xl,yl,zl]cy(a,q,r-B/3-.6,N); % Land[xc,yc,zc]cy(a,q,r0*B-1.1,N); % Cloud[xa,ya,za]cy(a,q,r0*B-1,N); % Atmospherezaza*1.1;% Custom colormap: landscapey with low value blue watercmpmax(copper,summer);cmp(1,:)[.1,.3,1]/2;% Now plotHhgtransform();surf(x,z,y,pa,H); % Ringmaterial([0,.1,.6,3]);hold on;surf(x,z,y,RL.*cat(3,0,1,1),AmbientS,1,pa,H); % Lighthold on;% Land, clouds, atmosphSsurf(xl,zl,yl,B,pa,H);wnsin(ag1/2); alph (1-wn).^3.*ones(N*U, 1); cp rescale(alph, 0.7, 1);cp cat(3, cp.^8, cp.^2.5, cp.^0.9); mm(x,y)material(x,y);S3surf(xc,zc,yc,0*xccat(3,1,1,1),FaceAlpha,flat,AlphaData,erf(C*4),pa,H); S2surf(xa,za,ya,cp,FaceAlpha,flat,AlphaData,alph.^.7);mm(S3,[1,0,0,5]);mm(S2,[.6,1,0,5]);mm(S,[0,1,.3,20]);colormap(cmp);caxis([0,.3]);axis equalshading flat% Add starsxrandn(3,900);xx./vecnorm(x)*20;scatter3(x(1,:),x(2,:),x(3,:),rand(900,1)*100,rand(900,1)*[1,1,1],.);hold off;% Axis / camera etc.shading flataxis equal offlight(position,[0,-20,0]);light(position,[10,10,5]);lighting(gouraud);shading flatset(gcf,color,k);camproj(perspective)camva(30);campos([78, -40, -40]/6);camtarget([-1, 0, -1]);endagslinspace(0,2*pi,49);oo(x)ifft2(x);Crescale(abs(real(oo(CS.*exp(1i*ags(f))))))-.5;X(x)max(repmat(x,[1,U]),0);CX(C); % Cloudscampos([78,-40sin(ags(f))*2,-40]/6) S3.AlphaDataerf(C*4); set(H,Ma, makehgtform(yrotate,(f-1)*pi/4/48)); end % Extra functions: % Make xyz cylinder coordinates function [x,y,z]cy(a,q,R,N)xcos(a).*R;ysin(a).*R;zq.*ones(N*8,1)*.9; end % Seam joiner function gs(g,N) dg(N,:)/2g(1,:)/2; g(1:4, :) d.*ones(4,1); g(end-3:end,:) d.*ones(4,1); endAugusto Mazzei这位大佬在第一周最后关头交上的非常炫酷且优质的作品 Augusto Mazzei / COLOR PULSE https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13775 1 function drawframe(f)% kishimisu I dont know who you are but you are GLSL god.% this is my transposed version in MATLAB.% https://www.shadertoy.com/view/mtyGWy% What Ive learned transposing GLSL to MATLAB:% vec.length vecnorm( vec,2,3)% vec.fract mod( vec, 1)% - all the rest is nearly pure math and talent.iRes cat(3, 800, 800); iTime f/47*3; persistent fragCoord if isempty(fragCoord)[x,y]meshgrid(1:iRes(1), 1:iRes(2));fragCoord cat(3,x,y); end img mainImage(fragCoord); imagesc(img) axis equal axis off function outpalette( t )cc ones(1,1,3);aa cc/2; dd reshape([0.263,0.416,0.557],1,1,3);out aa aa.*cos( 6.28318*( cc .* t dd) ); end function finalColormainImage( fragCoord )uv (fragCoord * 2 - iRes) / iRes(2);uv0 uv;finalColor 0;i0;while i 4uv mod(uv * 1.5, 1) - 0.5;d vecnorm(uv,2,3) .* exp(-vecnorm(uv0,2,3));col palette( vecnorm(uv0,2,3) i *0.4 iTime*0.4);d sin( d*10 iTime )/8;d abs(d);d (0.01 ./ d).^ 1.2;finalColor finalColor col .* d;ii1;end end endhiahiahia他甚至还弄了个自画像 Augusto Mazzei / PORTRAIT https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13475 function drawframe(f)if any(f1:4:48) hold off yy [198 189]; xx [388 554]; % I took these coordinates using drawpolygon eheh :) bocca [411 370;438 383;466 386;497 382;504 382;525 366;482 362;469 366;448 363]; nose[420 313;443 296;513 306;460 316]; eyeL [345 198;368 193;372 207;390 207;402 202;400 193;404 188;420 187;389 176;346 187]; neck[383 437;383 586;633 558;609 408]; eyebL[325 163;357 153;401 148;427 143;417 126;379 121;348 134]; eyebR[503 149;519 114;574 118;594 126;627 158;601 148;572 140;533 144]; nero[109 832;99 730;152 592;318 525;363 515;553 486;674 500;733 539;770 595;805 605;850 840;820 837;784 837];caps[228 72;255 79;280 29;291 13;680 4;695 44;699 128;677 174;656 249;653 112;587 121;619 97;517 109;582 66;487 92;541 35;436 118;400 118;468 69;360 109;302 144;302 246;272 157;264 170;248 143;252 112];rosso[377 474;336 658;404 595;449 699;654 574;672 535;627 437;621 486;416 592];rosa[295 222;280 204;278 253;297 333;323 357;331 392;368 458;442 495;522 484;599 443;636 370;649 316;679 280;690 202;685 183;657 200;661 97;628 18;317 20;290 108];marr [.3 .2 .14]; dra( nero,k); dra( neck,[1 .90 .90]); dra( rosso,[.63 .07 .18]); dra( rosa,[1 .94 .94]); dra( bocca,[.81 .67 .61]); dra( nose,[.95 .9 .9]); dra( caps,marr); dra( eyebL,marr); dra( eyebR,marr); for i1:2for j1:100drawc([xx(i)rand*5 -(yy(i)rand*5)])end end axis equal axis off set(gcf,color,[255,255,224]/255)end end function dra(a,c)fill(a(:,1),-a(:,2),c,EdgeCol,none); hold on end function drawc(c) r 10rand*6; aa 2*pi*linspace(0,1,randi([4 8])); fill( sin(aa)*rc(1)randn*5, randn*5cos(aa)*rc(2), hsv2rgb([rand .5 1]),...FaceAlpha,.5,EdgeColor,none); end以下是一个在比赛最开始几天非常惊艳的作品由Jenny Bosten大佬绘制 Jenny Bosten / Midnattsol https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12937 function drawframe(f) g1[45 129 191 64 148 195 135 178 210 158 196 215 170 207 216 210 219 218]; g2[120 110 119 142 119 113 167 123 88 194 134 72 206 142 68 219 142 28]; zlinspace(1,6,100); d[linspace(10,30,24) linspace(30,10,24)]; x(:,:,1)interp1(1:6,g1,z); x(:,:,2)interp1(1:6,g2,z); xpermute(x,[3 1 2]); xpermute(interp1([1,48],x,1:2:48),[2,3,1])./255; xcat(3,x,x(:,:,end:-1:1)); a1000; qlinspace(-235,235,48); mlinspace(pi,-pi,48); Xlinspace(-255,255,a); [t,r]cart2pol(X-q(f),100X-100*cos(m(f))); [x_i,y_i]find(r21); [x_i2,y_i2]find(r3); bx(:,:,f); j[1 1 .9]; colormap([j;flipud(b)]); r(r20)1; for k1:300 y(k,:)circshift(r(min(x_i),:),randi(100)-50); y(k,y_i2round(randi(round(d(f)))-d(f)/2))1; end imagesc([r(100:600,:);y]) axis equal axis off xlim([100 900]); end甚至还有人绘制了本场比赛的logo: Chen Lin / Mini Hack 2023 Logo https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13022 % Author:Eric Ludlam function drawframe(f) % Constantsbluevalidatecolor(#0076a8);darkbluevalidatecolor(#004b87);S.vertices [ 0 2 0; 1 2 0; % top1 0 0; 2 0 0; % middle0 -2 0; 1 -2 0; % bottom];S.faces [ 1 2 4 3;3 4 6 5;];S.facevertexcdata [ 1 ;1 ];% Convert our number into different animation stages.framemax floor(48/5); % 5 stagesstage ceil(f/framemax);f mod(f-1,framemax)1; % approx 9 frames per stageif stage 5stage 5;f f framemax;framemax framemax 4;end% Initializeif f1 stage1ax newplot;set(gcf, color,white);axis(ax, [ -2 6 -5 3 0 1 ])set(ax, position, [ 0 0 1 1], visible,off,tag,mh_ax)daspect(ax,[1 1.5 1]);clim([1 2]);colormap(ax,[ blue; darkblue]);p1 patch(vertices,[], faces, [], FaceColor, flat, EdgeColor, none, tag, chevron1);p2 patch(vertices,[], faces, [], FaceColor, flat, EdgeColor, none, tag, chevron2);txt text(0,0,, ...FontUnits, norm, ...FontSize, .17, ... % normalized units lets you resize this fig to any old size.Color, blue, ...VerticalAlignment, top,...HorizontalAlignment, center,...tag, mh_txt);elsep1 findobj(tag,chevron1);p2 findobj(tag,chevron2);txt findobj(tag,mh_txt);end% Animateswitch stagecase 1 % First chevron appearsxrng linspace(-4,0,framemax);x xrng(f);S.vertices S.vertices [ x 0 0 ];set(p1, S);set([txt p2], visible,off);case 2 % Flip downtmp S.vertices([1 2],:);yrng linspace(2,-2,framemax);tmp(:,2) yrng(f);S.vertices [ S.verticestmp ];S.faces [ S.faces3 4 8 7 ];S.facevertexcdata [ 1;1;2 ];set(p1, S);case 3 % Second chevron appearsxrng linspace(-4,2,framemax);x xrng(f);S.vertices S.vertices [ x 0 0 ];S.facevertexcdata(2) 2;set(p2, S, visible,on);case 4 % Minihack Txt appearsxrng linspace(-5,2,framemax);x xrng(f);clr sprintf(\\color[rgb]{%.2f,%.2f,%.2f}, darkblue);set(txt, visible,on, Position, [x -2.5], String, Mini \bf clr Hack);case 5 % Txt color changerrng linspace(darkblue(1),blue(1),framemax);grng linspace(darkblue(2),blue(2),framemax);brng linspace(darkblue(3),blue(3),framemax);clr sprintf(\\color[rgb]{%.2f,%.2f,%.2f}, rrng(f),grng(f),brng(f));set(txt,String, Mini \bf clr Hack);end end剩下一些不详细讲解了大家自己看叭~ Seth DeLand / Ray Tracing: Red Ball Rolls By https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13372 function drawframe(xx) % Inspiration: https://www.gabrielgambetta.com/computer-graphics-from-scratch/reflection.html %% Scene Setup vs [1.5 1]; % viewport size p 1; % projection plane O [0 0 0]; c eye(3); % Camera Rotation Cw 120; Ch 80; cnvs zeros(Cw1,Ch1,3); % Canvas of pixels b Sphere([8/47*xx-196/47 -1 3],1,[0 0 255],500,0.2); r Sphere([2 0 4],1,[255 0 0],500,0.3); g Sphere([-2 0 4],1,[0 255 0],10,0.4); y Sphere([0 -5001 0],5000,[0 255 255],1000,0.5); sp [r g b y]; l1 Light(amb,0.2,[],[]); l2 Light(pt,0.6,[2 1 0],[]); l3 Light(dir,0.2,[],[1 4 4]); ls [l1 l2 l3]; %% for i 1:Cw1 % For each column of pixelsx i-1-Cw/2;slc zeros(1,Ch,3);for j 1:Ch1 % For each row of pixelsy j-1-Ch/2;D C2V(x,y,Cw,Ch,vs,p);D (c*D);color TR(O,D,1,inf,sp,ls,3);slc(1,j,:) rot90(color);endcnvs(i,:,:) slc; end % Show the canvas, upsample by a factor of 2 imshow(imresize(rot90(uint8(cnvs)),2)); axis equal; end %% function D C2V(x,y,Cw,Ch,V,d)% Canvas to ViewportD [x*V(1)/Cw, y*V(2)./Ch, d]; end function c TR(O,D,ti,ta,sp,ls,rd)% Trace Ray% rd: recursion depth[cs,ct] CI(O,D,ti,ta,sp);if isempty(cs)c [0 0 0];returnelseP O ct*D; % Compute intersectionN P-cs.m; % Compute sphere normal at intersectionN N/norm(N);c cs.c*CL(P,N,ls,-D,cs.s,ta,sp);endr cs.rf;if ~(rd0 || r0)R RR(-D,N);rc TR(P,R,0.001,Inf,sp,ls,rd-1); % reflected colorc c*(1-r)rc*r;end end function [s,t] CI(O,D,t_min,t_max,sp)% CI: ClosestIntersectiont inf; % Distance to sheres []; % Spherefor i 1:length(sp)[t1,t2] IRS(O, D, sp(i));if t1t_min t1t_max t1 tt t1;s sp(i);endif t2t_min t2t_max t2 tt t2;s sp(i);endend end function i CL(P,N,ls,V,s,ta,sp)% Compute Lightingi 0;for l 1:length(ls)if strcmp(ls(l).t,amb) % Ambient lighti ils(l).i;elseif strcmp(ls(l).t,pt) % Point lightL ls(l).p - P;elseL ls(l).d; % Diffuse lightend% Shadow Checkss CI(P,L,0.001,ta,sp);if ~isempty(ss)continueend% Diffusen_dot_l dot(N,L);if n_dot_l0i i ls(l).i*n_dot_l/(norm(N)*norm(L));end% Specularif s ~ -1R RR(L,N);r_dot_v dot(R,V);if r_dot_v 0i i ls(l).i*(r_dot_v/(norm(R)*norm(V)))^s;endendendend end function r RR(R,N)% Reflect Rayr 2*N*dot(N,R)-R; end function [t1,t2] IRS(O,D,s)% IntersectRaySphereC s.m;r s.r;OC O - C;k1 dot(D, D);k2 2*dot(OC, D);k3 dot(OC, OC) - r*r;d k2*k2 - 4*k1*k3; % discriminantif d 0t1 inf;t2 inf;elset1 (-k2 sqrt(d)) / (2*k1);t2 (-k2 - sqrt(d)) / (2*k1);end end function l Light(t,i,p,d)% t: type (amb: ambient, pt: point, dir: directional)% i: intensity% p: position% d: directionl.t t;l.i i;l.p p;l.d d; end function s Sphere(cntr,r,col,spec,ref)% cntr: center% r: radius% col: color% spec: spectral% ref: reflectives.m cntr;s.r r;s.c col;s.s spec;s.rf ref; endAdam Danz / Rainy evening in the MATropolis https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13213 function drawframe(f) persistent handles if f 1 || isempty(handles)rng(default)axes(colormapgray,View[172,22],Colork)hold oncamva(3)hrandg(1,25); % building heightsbbar3(h);axis equalg.17; % height and width of windows[m,k]ndgrid(1:25); % (x,y) building indiceshandles.w gobjects(0);for i1:625 % loop through each building% Interpolate building color according to building height% Ideally this should be outside the loop but that would require more charactersqb(m(i));set(q,CData,q.ZData,FaceColor,interp)for j1:2 % loop through each column of windowsLk(i)-.27(j-1)*.37; % in k-a(j-1)*b, a is the signed distance from center of building in row k(i) to left edge of window in column j and b is the interval between left edges of windows.xL[0,g,g,0]; % [L;R;R;L] edges of windows in building i, window column jzones(4,1)*(.2:.4:h(i)-.2)[0;0;g;g]; % 4xn height of windows for n levels of windows; in a:b:c a is height of first row of windows, b is the interval between window-bottoms, c is height of tallest window.yz*0m(i).45; % 4xn location of front face of building% Plot windows for building i, column jfor w 1:width(z)handles.w(end1)patch(z(:,w)*0x,y(:,w),z(:,w),y);if rand(1) 0.25handles.w(end).FaceColor none;endendendendset(gcf,color,k)axis offcamva(2.5)campos([58.256 185.12 25.621])view([165.27, 7.0091])clim([0 8])% lightning lighthandles.light light(style,infinite,...Position,[-0.21759 1.3841 0.1921], ...Visible, off);% lightning backgroundax gca;handles.Z patch(ax.XLim([2,2,1,1]),...ax.YLim([1 1 1 1]),...ax.ZLim([1 2 2 1]),...[6 7.5 -3 -6],...Visible,off);handles.rain gobjects(1);xlim(xlim) % lazy way of freezing axis limitsylim(ylim)zlim(zlim) end % randomly toggle on/off some window lights p 0.001; % portion (0:1) of lights to toggle n numel(handles.w); idx randperm(n,ceil(n*p)); colors {handles.w(idx).FaceColor}; isnone cellfun(ischar, colors); set(handles.w(idx(isnone)), FaceColor, y) set(handles.w(idx(~isnone)), FaceColor, none) % Show lightning on select frames lightningFrames [24 26 28 29 31:34]; onoff ismember(f,lightningFrames); handles.light.Visible onoff; handles.Z.Visible onoff; % Rain if mod(f,2)0 % update every odd framehandles.rain.deletexyRain0 rand(3,300).*[26;26;10]-[0;0;2];xyRain1 xyRain0 [-1;0;-2]; % orientation and length of rain lineshandles.rain plot3([xyRain0(1,:);xyRain1(1,:)], ...[xyRain0(2,:);xyRain1(2,:)], ...[xyRain0(3,:);xyRain1(3,:)], ...color,[.7 .7 .7 .4]); end endJenny Bosten / Time lapse of Lake view to the West https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13760 function drawframe(f) persistent u n b M2 a2 a2_a r2 if f1 ulinspace; nrescale; bcircshift; q400; a1.65; m0; %sets up the colormap g[0.5373 0.1529 0.08240.6745 0.2353 0.11760.8706 0.3412 0.16470.9176 0.6353 0.24710.9843 0.9922 0.9725]; ginterp1(u(0,100,5),g,u(0,100,255)); g2g-.15; g2(g20)0; colormap([g;g2]); % for the sunset have 2 different colourmaps for the background and the % clouds then blend within each channel %declare some functions and variables to save characters Xu(1,255,200); %vector ranging between 1 and 255 200 long X2u(-1,1,400); %vector ranging between -1 and 1 400 long [t2,r2]cart2pol(X2,X2.1);%make radial gradient for the sun Mn(-r2(1:200,:),1,280);%or for sun Xu(-1,1,q); [t,r]cart2pol(X,X); %create r matrix for filter in fourier transform l1d(r,a); %generate 3 cloud layers using filtered noise function l2-d(r,a); l3d(r,a); i1round(u(1,q,48)); %create 2 sets of indices for slow and fast moving cloud layers i2round(u(1,800,48)); [x,y] meshgrid(0:399); %smaller first constant creates wider cloud band (line below). M3 exp(-.007*(y-290).^2/4^2); % gaussian envelope in matrix to keep clouds in a specified band. %pregenerate frames so all frames can be rescaled together for k1:48%pairs of matrices define the pixelmap and the alphaa1(:,:,1)n(l1,-6,8); %first cloud layer doesnt movea1_a(:,:,1)n(l1,-6,8);a1(:,:,2)n(b(l2,i2(k),2),-6,8); %second cloud layer traverses the image oncea1_a(:,:,2)n(b(l2,i2(k),2),-6,8);a1(:,:,3)n(b(-l3,i1(k),2),-6,8); %third cloud layer traverses the image twicea1_a(:,:,3)n(b(l3,i1(k),2),-6,8);a2(:,:,k)(max(a1,[],3)).*M3; %blend 3 cloud layers using a max functiona2_a(:,:,k)(max(a1_a,[],3)).*M3; %blend 3 cloud layers using a max function end a2n(abs(a2),-80,255); a2_an(a2_a,0,1); for k1:48M2(:,:,k)M.*(1-(a2_a(201:400,:,k)))(a2_a(201:400,:,k)).*a2(201:400,:,k); %blend alpha cloud layer with sky layer end %flip matrix and create sea currents using circshift M2n(M2,0,255); endDflip(M2(:,:,f))255;% reflection from waterM4M2(:,:,f);M4(r2(1:200,:)0.045)255;%set sun colourfor k130:200D(k1,197:203)255255-randi(80);M4[M4;b(D(k1,:),round(4*randn),2)];endimage(M4)axis equalaxis offcamva(4) function cd(r,a) crescale(abs(ifft2(fftshift(fft2(randn(400))).*(r.^-a))),0,1).^1; %function to create clouds end endAdam Danz / The MATropolis is ALIVE! https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13187 function drawframe(f) persistent h if f1 || isempty(h)%% plot the cityh struct(); % store graphics handles.rng(0) % the scene is customized for seed0 (twister)set(gcf,color,k)h.ax axes(Position[0 0 1 1],colormapgray,Colork,Projectionperspective);hold onaxis equalh.ax.XTickLabel ;h.ax.YTickLabel ;h.ax.ZTickLabel ;xlim([-27.76, 88.76])ylim([-4.5, 65.5])zlim([0,10.7])h.light light(po[-.7 .7 -1]);campos([1.3,33,7]) % zbuildingHeights(33) % plot3(1.3, 33,7,r*)camtarget([40 33 3])camva(70)buildingHeights randg(2,60); % building heightsh.bar bar3(h.ax,buildingHeights);set(h.bar,EdgeColor,k)% Loop through buildingsh.windows gobjects([2,size(buildingHeights)]);floorCount nan(size(buildingHeights));for i 1:height(buildingHeights)for j 1:width(buildingHeights)c 0.1:0.2:buildingHeights(i,j)-.2;floorCount(i,j) numel(c);d [c;c];z d(:)[0;0;.1;.1];y i[-.2,.2][-1;1;1;-1]/12;y repmat(y,size(c));ison logical(rand(1,numel(d))0.3); % some window lights will be offyellow [1,1,.05];p1 patch(h.ax,z(:,ison)*0j-.4,y(:,ison),z(:,ison),yellow);p2 patch(h.ax,z(:,~ison)*0j-.4,y(:,~ison),z(:,~ison),yellow);if ~isempty(p1)h.windows(1,i,j) p1;endif ~isempty(p2)p2.FaceColor none;h.windows(2,i,j) p2;endendendh.ax.XAxis.Visible off;h.ax.ZTick 0:5:10;h.ax.TickLength [0 0];grid(h.ax,on)h.ax.GridColor m;h.ax.GridAlpha 1; end %% Animate construction h.ax.GridAlpha 1-f/48; % Fade grid h.ax.CameraPosition(3) f/48*72; h.ax.CameraPosition(1) max(40-f/40*38.7,1.3); h.ax.CameraTarget(3) 2.2 - f/48*3.9; camva(50*f/4830) end我提交的一个作品 slandarer / moon bridge https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13382 function drawframe(n) global bl1 bl2 bl3 ml X1 X2 M L1600;H1400;S1000;R400;F550; x1(x)x.*80F40.*(rand(1)-.5); x2(x)x.*60F20040.*(rand(1)-.5); llinspace; ffill; if n1 rng(12) axgca; ax.XColornone; ax.YColornone; ax.XLim[0,L]; ax.YLim[0,H]; ax.DataAspectRatio[1 1 1]; hold on; rgb(C)hsv2rgb(C./[360,100,100]); cF[225 35 70]; % 远山的颜色 cM[210 70 10]; % 近山的颜色 cC[250 26 43]; % 云的颜色 cS[215 100 18]; % 天空的颜色 cN[253,252,222]./255; % 背景为远山的颜色 ax.Colorrgb(cM); % 画出天空颜色渐变效果 bprgb(cF)l(0,1,S).*(rgb(cS)-rgb(cF)); ip(1:S).*ones(1,L); Cind2rgb(ip,bp); [X,Y]meshgrid(1:L,401:H); surf(X,Y,X.*0,CData,C,EdgeColor,none); % 画出山脉效果 [X,Y]meshgrid(l(0,1,S)); CLX(-cos(X.*2.*pi)1).^.2; CLY(-cos(Y.*2.*pi)1).^.2; r(X-.5).^2(Y-.5).^2; % 8层山 for i1:8% 每次都生成一次二维随机噪声并取其中一行的数据habs(ifftn(exp(5i*rand(S))./r.^1.05)).*(CLX.*CLY).*24;nh(8-i)*30h(500,:);if i1,nhnh.*.8;endhmceil(max(nh));Cones(hm,S);% 颜色矩阵构造tcolcF(cM-cF)./8.*(i);tcolrgb(tcol);Cind2rgb(C,tcol);% 用nan数值框出山的轮廓aones(hm,S);a((1:hm)nh)nan;% 绘制山峰image([-50,L50],[R,Rhm],C,AlphaData,a.*0.98); end % 绘制月亮和云朵 t1l(-pi/2,pi/2,100); t2l(pi/2,3*pi/2,100); X1cos(t1).*80;Y1sin(t1).*80; X2cos(t2).*80;Y2sin(t2).*80; mlf([X1,X2]1350,[Y1,Y2]1200,cN,EdgeColor,none); aabs(ifftn(exp(3i*rand(S))./r.^.8)).*(CLX.*CLY); aa./max(a,[],all); Cones(size(a)); Cind2rgb(C,rgb(cC)); % 越向下、云越透明 dy(1:S)./S.*0.80.2; image([0,L],[800,H],C,AlphaData,a.*(dy)); bprgb(cF)l(0,1,R).*(rgb(cM)-rgb(cF)); ip(1:R).*ones(1,L); Cind2rgb(ip,bp); [X,Y]meshgrid(1:L,0:R); surf(X,Y,X.*0,CData,C,EdgeColor,none); % 绘制石头桥 Xl(100,S,100); Ysin(l(0,pi,100)); f(X,Y.*150R,[.1,.1,.1],EdgeColor,none) plot(X,Y.*150R,Color,[cN,.3],LineWidth,1) Tl(0,pi,100); f(cos(T).*80F,sin(T).*80R,cN,EdgeColor,none); f(cos(T).*60F200,sin(T).*60R,cN,EdgeColor,none); f(cos(T).*60F-200,sin(T).*60R,cN,EdgeColor,none); for i1:7y(i-1)/6;x[-1,1].*sqrt(1-y.^2);cp{Color,cN,LineWidth,1};bl1(i)plot(x1(x),R-[y,y].*90,cp{:});bl2(i)plot(x2(x),R-[y,y].*60,cp{:});bl3(i)plot(x2(x)-R,R-[y,y].*60,cp{:}); end elsekl(-1,1,48);tX2X2.*k(n);ml.XData[X1,tX2]1350;for i1:7y(i-1)/6;x[-1,1].*sqrt(1-y.^2);set(bl1(i),XData,x1(x));set(bl2(i),XData,x2(x));set(bl3(i),XData,x2(x)-R);end end end由于这一周属实太忙我交的很多作品都是原本代码的修改版本在公众号或者知乎都找得到因此就不都放代码了大家感兴趣可以去投个票玩hiahiahia: https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12797 https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12777 https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12757 https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12742 https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/12787 完 比赛还有20天才结束感兴趣的快去参加 https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries
http://www.laogonggong.com/news/126731.html

相关文章:

  • 基于html5的网站开发网站开发公司哪里好
  • 小鼠标网站建设注册一个公司需要几个人
  • 唐山有制作网站的没网络营销网站建设诊断报告
  • 网站建设的详细步骤app开发公司掌握我的源代码吗
  • 网站目录做二级域名网加速器
  • 张店网站开发招聘销售网站怎么做的
  • 做网站付多少定金深圳福田专业网站推广
  • 凡科建站官网地址网站建设 锋云科技
  • 笨笨网站建设专家随州网站建设学校
  • 网站建设服务费是否无形资产美工详情页设计一般多少钱
  • 泉州专门做网站怎么制作营销网站
  • 网站建设哪家好建议兴田德润北京seo优化方案
  • 选手机网站wordpress图片主题演示
  • 新手怎样学校做网站芍药居做网站公司
  • 电商网站建设包括哪些内容做一手房有哪些网站比较好啊
  • 个人品牌网站设计泰安网站建设焦点网络
  • 广州微信网站建设价格人人站cms
  • 网站开发辛苦吗万网官方网站
  • 网站文章排版工具厦门建设与管理局官网
  • googleseo排名公司曲靖seo
  • 网站优化有哪些方法久久建筑网农网改造工程钻孔机开挖基坑专项施工方案
  • 北京网站制作17页ps软件免费下载安装
  • wordpress回收站在哪如何用本机电脑做网站服务器
  • 昆山网站建设培训学校厂房出租做推广什么网站好
  • 郑州建网站哪个公司好安卓市场2022最新版下载
  • 九江集团网站建设公司商城网站开发报价
  • 哪里有营销型网站制作深圳网站建设科技有限公司
  • 锦州网站建设怎样专业团队搞笑图片
  • 网站维护的重要性百度申诉网站
  • wordpress国内网站吗开通公众号的流程