MATLAB | 官方举办的动图绘制大赛 | 第一周赛情回顾

news2024/12/30 3:05:57

嘿真的又是很久没见了,最近确实有点非常很特别小忙,今天带来一下MATHWORKS官方举办的迷你黑客大赛第三期(MATLAB Flipbook Mini Hack)的最新进展!!目前比赛已经刚好进行了一周,前两届都要求提交280个字符内的代码来生成图片,但是这一届,要求提交2000个字符内的代码来生成动画,字符限制一放开大家就开始有种各显神通的意思,仅仅一周就贡献了接近200个优质作品

本次比赛要求提交名为drawframe(f)的函数代码,生成长达2s,48帧的动态图,动图生成是依靠如下代码来做到的:

function contestAnimator()
    animFilename = 'animation.gif'; % Output file name
    firstFrame = true;
    framesPerSecond = 24;
    delayTime = 1/framesPerSecond;
    % Create the gif
    for frame = 1:48
        drawframe(frame)
        fig = gcf(); 
        fig.Units = 'pixels';
        fig.Position(3:4) = [300,300];
        im = getframe(fig);
        [A,map] = rgb2ind(im.cdata,256);
        if firstFrame
            firstFrame = false;
            imwrite(A,map,animFilename, LoopCount=Inf, DelayTime=delayTime);
        else
            imwrite(A,map,animFilename, WriteMode="append", DelayTime=delayTime);
        end
    end
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 time
    persistent enz ags x d c mx my mn cmp
    if nn == 1        
        % Everything is precomputed so we don't really need this -> undo to
        % get different clouds each time
        rng default
        
        % Base vector for pixels
        x = linspace(-1, 1, 240);
        
        % Make complex 3D noise spectrum -> spectrally shaping using
        % distance. This is expensive so only do once.
        b=length(x);
        d=x(1:2:end)/2;
        c=length(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 + (my+0.2).^2;
        mn = 1 - erf(max(rd - 0.3, 0)*3);
        
        % Custom colormap for clouds
        cmp = 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 noise
    dt = 5*dt.*(d-d(1))'.*permute(erf((x - 0.1)*2)+1, [1, 3, 2]);
    dt = dt(:, :, 1:end);
    
    % Thresholding for transparency
    ap = dt>0.08;
    % Making it look like clouds / adding glint
    c_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 Matlab's 3D rendering is so slow that this fails to execute if
    % you use surf to blend the images, so let's use the alpha-blender used
    % to flatten the clouds for the RGB background, moon and cloud layers
    
    % Convert clouds to RGB image using custom colormap
    C = round(min(AI*40, 1)*255+1);
    C = double(ind2rgb(C, cmp));
      
    % Permuter to work with alpha blending function convention
    PP = @(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 function
    function [AIf, ASf] = P(ATf, CLSf)
        ASf = ATf(1, :, :);
        AIf = CLSf(1, :, :);
        % Have alpha, have intensity, compress onto single plane using alpha
        % blending formula
        for nf = 2:size(ATf, 1)
            APf = ASf;
            ASf = APf + ATf(nf, :, :).*(1-APf);
            AIf = (AIf.*APf + CLSf(nf, :, :).*ATf(nf, :, :).*(1-APf))./(eps + ASf);
        end
    end
end

Tim / 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;
r=6;                            % Torus radius
N=80;                           % Texture resolution. Set to higher on your own computer for improvements.
                                % (Has longer rendering times!)
R=zeros(N, N*8);                % Initial torus radius
R(:,N/2:N:end)=-.02;            % Notches every bit
R=conv2(R,[1:4,3:-1:1],'same');                         % Fare the notches
R=R+conv2(randn(size(R))/500,ones(3)/9,'same')+1;       % Add some random noise. Probably doesn't 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);
ag1=l(N)';
ag2=l(N*8);
% This will be the tunnel
b=R.*cos(ag1);
z=R.*sin(ag1);
x=b.*cos(ag2)+r*cos(ag2);
y=b.*sin(ag2)+r*sin(ag2);;
% This will be the algae growing on the pipe
R2=R*.99;
b=R2.*cos(ag1);
z2=R2.*sin(ag1);
x2=b.*cos(ag2)+r*cos(ag2);
y2=b.*sin(ag2)+r*sin(ag2);
% This will eventually be the water at the bottom
rd=linspace(4, 8, N)';
xd=rd.*cos(ag2);
yd=rd.*sin(ag2);
% Make camera positions
ag=linspace(0,2*pi,48*4);
cpx=r*cos(ag);
cpy=r*sin(ag);
cpz=zeros(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));
rd=sqrt(xx.^2+yy.^2);
sgnO=((randn(N, N*8)+1i*randn(N, N*8))./((ifftshift(rd.^2)+1e-5)));
sgnO=ifft2(sgnO(:,[1:N,end-N+1: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))));
sg=real(ifft2(sg(:, 1:N*2)));
sg=[sg,sg,sg,sg];
sg=erf(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
ags=linspace(0, pi/4, 49);
ags=ags(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.3+0.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.2+0.8).*clrF, 'FaceAlpha', 'flat', 'AlphaData', erf(rescale(1-sg)*2+0.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(nn+18), cpy(nn+18), cpz(nn+18)-0.4]);
% Headlight: one doesn't 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.
end

Tim / Ring world

https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13660

function drawframe(f)
% Ring world...
persistent H CS S3 U
if f==1
    rng(2,'v4')
    % % % % Make the ring % % % %
    r=6;                % Radius
    N=60;              % Number of edge-pixels on base unit
    U=8;                % Rotating by 1/8 of a circle
    % Add texture to ring. Make it tech-y
    R=zeros(N,N);
    R(randi(N^2, 3))=1;
    k1=ones(N/2)/10;
    k2=k1;
    k2(2:end-1,2:end-1)=0;      % Kernel for glowing lights
    RL=conv2(R,k2,'same');      % Glowing lights
    R=conv2(R,k1,'same');       % Surface
    % Tiling
    R=repmat(R,[1,U])+1;
    RL=repmat(RL,[1,U]);
    % Fix seams. Expendable code.
    R=s(R,N);
    RL=s(RL,N);
    RB=(R-1)/2;
    RL=RL./RL;
    % Notch to fit the land in...
    NH=N/2;
    NW=floor(N/6);
    R(NH-NW+1:NH+NW, :)=0;
    % Make our angles
    l=@(x)linspace(0,2*pi,x);
    ag1=l(N)';
    a=l(N*U);
    c=cos(a);
    v=sin(a);
    % Ring torus
    b=erf(R.*cos(ag1)*5)+RB;   % Make it square-ish
    z=R.*sin(ag1);
    x=b.*c+r*c;
    y=b.*v+r*v;
    % % % % Make the land inside.
    % Spectral noise shaping... land mass will be a noisy cylinder
    q=linspace(-1,1,N);
    rand(8);
    k=@()exp(6i*randn(N))./(q.^2+q'.^2+2e-4);
    oo=@(x)ifft2(x);
    B=rescale(abs(oo(k())))-.3;
    CS=k();
    C=rescale(abs(real(oo(CS.*exp(1i*.10)))))-.5;
    X=@(x)max(repmat(x,[1,U])',0);
    B=X(B)/2;    % Max makes the water
    C=X(C);      % Clouds
    % Assemble the cylinder   s 
    [xl,yl,zl]=cy(a',q,r-B/3-.6,N);      % Land
    [xc,yc,zc]=cy(a',q,r+0*B-1.1,N);     % Cloud
    [xa,ya,za]=cy(a',q,r+0*B-1,N);       % Atmosphere
    za=za*1.1;
    % Custom colormap: landscapey with low value = blue = water
    cmp=max(copper,summer);
    cmp(1,:)=[.1,.3,1]/2;
    % Now plot
    H=hgtransform();
    surf(x,z,y,'pa',H);          % Ring
    material([0,.1,.6,3]);
    hold on;
    surf(x,z,y,RL.*cat(3,0,1,1),'AmbientS',1,'pa',H);          % Light
    hold on;
    % Land, clouds, atmosph
    S=surf(xl,zl,yl,B,'pa',H);
    wn=sin(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);
    S3=surf(xc,zc,yc,0*xc+cat(3,1,1,1),'FaceAlpha','flat','AlphaData',erf(C*4),'pa',H);    
    S2=surf(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 equal
    shading flat
    
    % Add stars
    x=randn(3,900);
    x=x./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 flat
    axis equal off
    light('position',[0,-20,0]);
    light('position',[10,10,5]);
    lighting('gouraud');
    shading flat
    set(gcf,'color','k');
    camproj('perspective')
    camva(30);
    campos([78, -40, -40]/6);
    camtarget([-1, 0, -1]);
    
end
    ags=linspace(0,2*pi,49);
    oo=@(x)ifft2(x);
    C=rescale(abs(real(oo(CS.*exp(1i*ags(f))))))-.5;
    X=@(x)max(repmat(x,[1,U])',0);
    C=X(C);      % Clouds
    
campos([78,-40+sin(ags(f))*2,-40]/6)
S3.AlphaData=erf(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)
    x=cos(a).*R;
    y=sin(a).*R;
    z=q.*ones(N*8,1)*.9;
end
% Seam joiner
function g=s(g,N)
d=g(N,:)/2+g(1,:)/2;
g(1:4, :) = d.*ones(4,1);
g(end-3:end,:) = d.*ones(4,1);
end

Augusto Mazzei这位大佬在第一周最后关头交上的非常炫酷且优质的作品:

Augusto Mazzei / COLOR PULSE

https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13775

1

function drawframe(f)
    % @"kishimisu" I don't know who you are but you are GLSL god.
    % this is my transposed version in MATLAB.
    % https://www.shadertoy.com/view/mtyGWy
    % What I've 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 out=palette( 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 finalColor=mainImage( fragCoord )
    
    uv = (fragCoord * 2 - iRes) / iRes(2);
    uv0 = uv;
    finalColor = 0;
    i=0;
    while i < 4
        uv = 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;
        i=i+1;
    end
end
end

hiahiahia他甚至还弄了个自画像:

Augusto Mazzei / PORTRAIT

https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13475

function drawframe(f)
 
    if any(f==1: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 i=1:2
    for j=1:100
    drawc([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 = 10+rand*6;    
aa = 2*pi*linspace(0,1,randi([4 8]));
fill( sin(aa)*r+c(1)+randn*5, randn*5+cos(aa)*r+c(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];
z=linspace(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);
x=permute(x,[3 1 2]);
x=permute(interp1([1,48],x,1:2:48),[2,3,1])./255;
x=cat(3,x,x(:,:,end:-1:1));
a=1000;
q=linspace(-235,235,48);
m=linspace(pi,-pi,48);
X=linspace(-255,255,a);
[t,r]=cart2pol(X-q(f),100+X'-100*cos(m(f)));
[x_i,y_i]=find(r<21);
[x_i2,y_i2]=find(r<3);
b=x(:,:,f);
j=[1 1 .9];
colormap([j;flipud(b)]);
r(r<20)=1;
for k=1:300
y(k,:)=circshift(r(min(x_i),:),randi(100)-50);
y(k,y_i2+round(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)
% Constants
    blue=validatecolor("#0076a8");
    darkblue=validatecolor("#004b87");
    
    S.vertices = [ 0 2 0; 1 2 0;  % top
                   1 0 0; 2 0 0;  % middle
                   0 -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 stages
    stage = ceil(f/framemax);
    f = mod(f-1,framemax)+1;  % approx 9 frames per stage
    if stage > 5
        stage = 5;
        f = f + framemax;
        framemax = framemax + 4;
    end
    % Initialize
    if f==1 && stage==1
        ax = 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');
    else
        p1 = findobj('tag','chevron1');
        p2 = findobj('tag','chevron2');
        txt = findobj('tag','mh_txt');
    end
    % Animate
    switch stage
      case 1 % First chevron appears
        xrng = 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 down
        tmp = S.vertices([1 2],:);
        yrng = linspace(2,-2,framemax);
        tmp(:,2) = yrng(f);
        S.vertices = [ S.vertices
                       tmp ];
        S.faces = [ S.faces
                    3 4 8 7 ];
        S.facevertexcdata = [ 1;1;2 ];
        set(p1, S);
      case 3 % Second chevron appears
        xrng = 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 appears
        xrng = 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 change
        rrng = 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(Cw+1,Ch+1,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:Cw+1 % For each column of pixels
    x = i-1-Cw/2;
    slc = zeros(1,Ch,3);
    for j = 1:Ch+1 % For each row of pixels
        y = 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);
    end
    cnvs(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 Viewport
    D = [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];
        return
    else
        P = O + ct*D; % Compute intersection
        N = P-cs.m; % Compute sphere normal at intersection
        N = N/norm(N);
        c = cs.c*CL(P,N,ls,-D,cs.s,ta,sp);
    end
    r = cs.rf;
    if ~(rd<=0 || r<=0)
        R = RR(-D,N);
        rc = TR(P,R,0.001,Inf,sp,ls,rd-1); % reflected color
        c = c*(1-r)+rc*r;
    end
end
function [s,t] = CI(O,D,t_min,t_max,sp)
    % CI: ClosestIntersection
    t = inf; % Distance to shere
    s = []; % Sphere
    for i = 1:length(sp)
        [t1,t2] = IRS(O, D, sp(i));
        if t1>t_min && t1<t_max && t1 < t
            t = t1;
            s = sp(i);
        end
        if t2>t_min && t2<t_max && t2 < t
            t = t2;
            s = sp(i);
        end
    end
end
function i = CL(P,N,ls,V,s,ta,sp)
    % Compute Lighting
    i = 0;
    for l = 1:length(ls)
        if strcmp(ls(l).t,'amb') % Ambient light
            i = i+ls(l).i;
        else
            if strcmp(ls(l).t,'pt') % Point light
                L = ls(l).p - P;
            else
                L = ls(l).d; % Diffuse light
            end
            
            % Shadow Check
            ss = CI(P,L,0.001,ta,sp);
            if ~isempty(ss)
                continue
            end
            
            % Diffuse
            n_dot_l = dot(N,L);
            if n_dot_l>0
                i = i + ls(l).i*n_dot_l/(norm(N)*norm(L));
            end
            
            % Specular
            if s ~= -1
                R = RR(L,N);
                r_dot_v = dot(R,V);
                if r_dot_v > 0
                    i = i + ls(l).i*(r_dot_v/(norm(R)*norm(V)))^s;
                end
            end
        end
    end
end
function r = RR(R,N)
    % Reflect Ray
    r = 2*N*dot(N,R)-R;
end
function [t1,t2] = IRS(O,D,s)
    % IntersectRaySphere
    C = 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; % discriminant
    if d < 0
        t1 = inf;
        t2 = inf;
    else
        t1 = (-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: direction
    l.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: reflective
    s.m = cntr;
    s.r = r;
    s.c = col;
    s.s = spec;
    s.rf = ref;
end

Adam 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(colormap=gray,View=[172,22],Color='k')
    hold on
    camva(3)
    h=randg(1,25);          % building heights
    b=bar3(h);
    axis equal
    g=.17;                  % height and width of windows
    [m,k]=ndgrid(1:25);     % (x,y) building indices
    handles.w = gobjects(0);
    for i=1:625             % loop through each building
        % Interpolate building color according to building height
        % Ideally this should be outside the loop but that would require more characters
        q=b(m(i));
        set(q,'CData',q.ZData,'FaceColor','interp')
        for j=1:2                   % loop through each column of windows
            L=k(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.
            x=L+[0,g,g,0]';         % [L;R;R;L] edges of windows in building i, window column j
            z=ones(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.
            y=z*0+m(i)+.45;          % 4xn location of front face of building
            % Plot windows for building i, column j
            for w = 1:width(z)
                handles.w(end+1)=patch(z(:,w)*0+x,y(:,w),z(:,w),'y');
                if rand(1) < 0.25
                    handles.w(end).FaceColor = 'none';
                end
            end
        end
    end
    set(gcf,'color','k')
    axis off
    camva(2.5)
    campos([58.256 185.12 25.621])
    view([165.27, 7.0091])
    clim([0 8])
    % lightning light
    handles.light = light('style','infinite',...
        'Position',[-0.21759 1.3841 0.1921], ...
        'Visible', 'off');
    % lightning background
    ax = 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 limits
    ylim(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 frame
    handles.rain.delete
    xyRain0 = rand(3,300).*[26;26;10]-[0;0;2];
    xyRain1 = xyRain0 + [-1;0;-2]; % orientation and length of rain lines
    handles.rain = plot3([xyRain0(1,:);xyRain1(1,:)], ...
        [xyRain0(2,:);xyRain1(2,:)], ...
        [xyRain0(3,:);xyRain1(3,:)], ...
        'color',[.7 .7 .7 .4]);
end
end

Jenny 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 f==1
u=@linspace;
n=@rescale;
b=@circshift;
q=400;
a=1.65;
m=0;
%sets up the colormap
g=[0.5373    0.1529    0.0824
    0.6745    0.2353    0.1176
    0.8706    0.3412    0.1647
    0.9176    0.6353    0.2471
    0.9843    0.9922    0.9725];
g=interp1(u(0,100,5),g,u(0,100,255));
g2=g-.15;
g2(g2<0)=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
X=u(1,255,200); %vector ranging between 1 and 255 200 long
X2=u(-1,1,400); %vector ranging between -1 and 1 400 long
[t2,r2]=cart2pol(X2,X2'+.1);%make radial gradient for the sun
M=n(-r2(1:200,:),1,280);%or for sun
X=u(-1,1,q);
[t,r]=cart2pol(X,X'); %create r matrix for filter in fourier transform
l1=d(r,a); %generate 3 cloud layers using filtered noise function
l2=-d(r,a);
l3=d(r,a);
i1=round(u(1,q,48)); %create 2 sets of indices for slow and fast moving cloud layers
i2=round(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 k=1:48
    %pairs of matrices define the pixelmap and the alpha
    a1(:,:,1)=n(l1,-6,8); %first cloud layer doesn't move
    a1_a(:,:,1)=n(l1,-6,8);
    a1(:,:,2)=n(b(l2,i2(k),2),-6,8); %second cloud layer traverses the image once
    a1_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 twice
    a1_a(:,:,3)=n(b(l3,i1(k),2),-6,8);
    a2(:,:,k)=(max(a1,[],3)).*M3; %blend 3 cloud layers using a max function
    a2_a(:,:,k)=(max(a1_a,[],3)).*M3; %blend 3 cloud layers using a max function
end
a2=n(abs(a2),-80,255);
a2_a=n(a2_a,0,1);
for k=1:48
    M2(:,:,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
M2=n(M2,0,255);
end
        D=flip(M2(:,:,f))+255;
         % reflection from water
        M4=M2(:,:,f);
        M4(r2(1:200,:)<0.045)=255;%set sun colour
        for k1=30:200
            D(k1,197:203)=255+255-randi(80);
            M4=[M4;b(D(k1,:),round(4*randn),2)];
        end
        image(M4)
        axis equal
        axis off
        camva(4)
function c=d(r,a)
c=rescale(abs(ifft2(fftshift(fft2(randn(400))).*(r.^-a))),0,1).^1; %function to create clouds
end
end

Adam Danz / The MATropolis is ALIVE!

https://ww2.mathworks.cn/matlabcentral/communitycontests/contests/6/entries/13187

function drawframe(f)
persistent h
if f==1 || isempty(h)
    %% plot the city
    h = struct();  % store graphics handles.
    rng(0) % the scene is customized for seed=0 (twister)
    set(gcf,'color','k')
    h.ax = axes(Position=[0 0 1 1],colormap=gray,Color='k',Projection='perspective');
    hold on
    axis equal
    h.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]) % z=buildingHeights(33)  % plot3(1.3, 33,7,'r*')
    camtarget([40 33 3])
    camva(70)
    buildingHeights = randg(2,60); % building heights
    h.bar = bar3(h.ax,buildingHeights);
    set(h.bar,'EdgeColor','k')
    % Loop through buildings
    h.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 off
            yellow = [1,1,.05];
            p1 = patch(h.ax,z(:,ison)*0+j-.4,y(:,ison),z(:,ison),yellow);
            p2 = patch(h.ax,z(:,~ison)*0+j-.4,y(:,~ison),z(:,~ison),yellow);
            if ~isempty(p1)
                h.windows(1,i,j) = p1;
            end
            if ~isempty(p2)
                p2.FaceColor = 'none';
                h.windows(2,i,j) = p2;
            end
        end
    end
    h.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*7+2;
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/48+30)
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
L=1600;H=1400;S=1000;R=400;F=550;
x1=@(x)x.*80+F+40.*(rand(1)-.5);
x2=@(x)x.*60+F+200+40.*(rand(1)-.5);
l=@linspace;
f=@fill;
if n==1
rng(12)
ax=gca;
ax.XColor='none';
ax.YColor='none';
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.Color=rgb(cM);
% 画出天空颜色渐变效果 ======================================================
bp=rgb(cF)+l(0,1,S)'.*(rgb(cS)-rgb(cF));
ip=(1:S)'.*ones(1,L);
C=ind2rgb(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 i=1:8
    % 每次都生成一次二维随机噪声,并取其中一行的数据
    h=abs(ifftn(exp(5i*rand(S))./r.^1.05)).*(CLX.*CLY).*24;
    nh=(8-i)*30+h(500,:);
    if i==1,nh=nh.*.8;end
    hm=ceil(max(nh));
    C=ones(hm,S);
    % 颜色矩阵构造
    tcol=cF+(cM-cF)./8.*(i);
    tcol=rgb(tcol);
    C=ind2rgb(C,tcol);
    % 用nan数值框出山的轮廓
    a=ones(hm,S);
    a((1:hm)'>nh)=nan;
    % 绘制山峰
    image([-50,L+50],[R,R+hm],C,'AlphaData',a.*0.98);
end
% 绘制月亮和云朵 ===========================================================
t1=l(-pi/2,pi/2,100);
t2=l(pi/2,3*pi/2,100);
X1=cos(t1).*80;Y1=sin(t1).*80;
X2=cos(t2).*80;Y2=sin(t2).*80;
ml=f([X1,X2]+1350,[Y1,Y2]+1200,cN,'EdgeColor','none');
a=abs(ifftn(exp(3i*rand(S))./r.^.8)).*(CLX.*CLY);
a=a./max(a,[],'all');
C=ones(size(a));
C=ind2rgb(C,rgb(cC));
% 越向下、云越透明
dy=(1:S)./S.*0.8+0.2;
image([0,L],[800,H],C,'AlphaData',a.*(dy'));
bp=rgb(cF)+l(0,1,R)'.*(rgb(cM)-rgb(cF));
ip=(1:R)'.*ones(1,L);
C=ind2rgb(ip,bp);
[X,Y]=meshgrid(1:L,0:R);
surf(X,Y,X.*0,'CData',C,'EdgeColor','none');
% 绘制石头桥 ===============================================================
X=l(100,S,100);
Y=sin(l(0,pi,100));
f(X,Y.*150+R,[.1,.1,.1],'EdgeColor','none')
plot(X,Y.*150+R,'Color',[cN,.3],'LineWidth',1)
T=l(0,pi,100);
f(cos(T).*80+F,sin(T).*80+R,cN,'EdgeColor','none');
f(cos(T).*60+F+200,sin(T).*60+R,cN,'EdgeColor','none');
f(cos(T).*60+F-200,sin(T).*60+R,cN,'EdgeColor','none');
for i=1:7
    y=(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
else
    k=l(-1,1,48);
    tX2=X2.*k(n);
    ml.XData=[X1,tX2]+1350;
    for i=1:7
        y=(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.coloradmin.cn/o/1205408.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一个关于jdbc操作mysql和java基础练手的通讯录管理系统小项目

首先 : 整个项目的项目结构为 : 1.第一步先导入数据库的驱动&#xff0c;我的mysql数据库是8.0以上版本&#xff0c;然后导入的驱动就是8.0.16版本的jar包&#xff1b; 1.JdbcBase : JDBC基础操作封装成了JdbcBase类,在里面先静态定义了数据库连接对象和DQL查询结果&#x…

C++阶段复习‘‘‘‘总结?【4w字。。。】

文章目录 前言类和对象C类定义和对象定义类成员函数C 类访问修饰符公有&#xff08;public&#xff09;成员私有&#xff08;private&#xff09;成员受保护&#xff08;protected&#xff09;成员 继承中的特点类的构造函数和析构函数 友元函数内联函数this指针指向类的指针类…

蓝桥杯 冒泡排序

冒泡排序的思想 冒泡排序的思想是每次将最大的一下一下移动到最右边&#xff0c;然后将最右边这个确定下来。 再来确定第二大的&#xff0c;再确定第三大的… 对于数组a[n]&#xff0c;具体来说&#xff0c;每次确定操作就是从左往右扫描&#xff0c;如果a[i]>a[i1],我们将…

Prim算法(C++)

目录 介绍&#xff1a; 代码&#xff1a; 结果&#xff1a; 介绍&#xff1a; Prim算法是一种用于解决最小生成树问题的贪心算法。该算法的主要思想是从一个顶点开始&#xff0c;不断向图中添加边&#xff0c;直到构成一棵包含所有顶点的生成树&#xff0c;使得树的边权之…

VSCode 好用的插件分享

文章目录 Introlistcode runner 【在文本编辑器中编辑好各类语言的源代码&#xff0c;然后一键运行】gitlens - 【git提交信息即时查看&#xff0c;类似IDEA中的 show annotation】还有更多&#xff0c;会日常补充。 Intro 大四毕业前&#xff0c;我只有一台dell latitude 455…

Vue 小黑记事本组件板

渲染功能&#xff1a; 1.提供数据&#xff1a; 提供在公共的父组件 App.vue 2.通过父传子&#xff0c;将数据传递给TodoMain 3.利用 v-for渲染 添加功能&#xff1a; 1.收集表单数据 v-model 2.监听事件&#xff08;回车点击都要添加&#xff09; 3.子传父&#xff0c;讲…

Vue3 + Three.js + gltf-pipeline大型园区场景渲染与3D业务

在非使用unity作为3D渲染方案的前提下&#xff0c;对与目前web开发者比较友好的除了canvas场景需要的2D babylon.js&#xff0c;fabric.js, Three.js是目前针对于jsWeb用户最直接且比较友好的3D引擎方案了。 准备工作&#xff1a; 1.明确需要用的场景方案都有那些&#xff0c;模…

创建maven的 java web项目

创建maven的 java web项目 创建出来的项目样子 再添加java和resources文件夹 一定要如图有文件夹下有图标才代表被IDEA识别&#xff0c;不让是不行的 没有的话在File——ProjectStructure中进行设置

EasyDarwin开源流媒体服务器

文章目录 前言一、EasyDarwin 简介二、EasyDarwin 主要功能特点三、安装部署四、推拉流测试1、进入控制页面2、推流测试3、拉流测试 前言 本文介绍一个十分实用的高性能开源 RTSP 流媒体服务器&#xff1a;EasyDarwin。 一、EasyDarwin 简介 EasyDarwin 是基于 go 语言研发&a…

域名反查Api接口——让您轻松查询域名相关信息

在互联网发展的今天&#xff0c;域名作为网站的唯一标识符&#xff0c;已经成为了企业和个人网络营销中不可或缺的一部分。为了方便用户查询所需的域名信息&#xff0c;API接口应运而生。本文将介绍如何使用挖数据平台《域名反查Api接口——让您轻松查询域名相关信息》进行域名…

【Java笔试强训】Day10(CM62 井字棋、HJ87 密码强度等级)

CM62 井字棋 链接&#xff1a;井字棋 题目&#xff1a; 给定一个二维数组board&#xff0c;代表棋盘&#xff0c;其中元素为1的代表是当前玩家的棋子&#xff0c;0表示没有棋子&#xff0c;-1代表是对方玩家的棋子。当一方棋子在横竖斜方向上有连成排的及获胜&#xff08;及…

Ps:通过显示大小了解图像的打印尺寸

在 Photoshop 中&#xff0c;如果想了解文档窗口中的图像打印出来之后的实质大小&#xff0c;只要知道两个数值即可。 第一个数值是图像分辨率&#xff08;也称“文档分辨率”&#xff09;的大小&#xff0c;可在Ps菜单&#xff1a;图像/图像大小 Image Size对话框中查询或设置…

linux 安装 mini conda,linux下安装 Miniconda

下载地址 https://docs.conda.io/projects/miniconda/en/latest/index.html 安装conda mkdir -p ~/miniconda3 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh bash ~/miniconda3/miniconda.sh -b -u -p ~/mini…

第1关:构造函数与析构函数的实现

题目&#xff1a;根据.h写出.cpp 考点&#xff1a; 1.链表的默认构造&#xff0c; 拷贝构造&#xff0c;传参构造以及析构函数等。 代码&#xff1a; /********** BEGIN **********/ #include <cstdlib> #include <cstring> #include "LinkedList.h&…

Java 设计模式——组合模式

目录 1.概述2.结构3.实现3.1.抽象构件3.2.容器构件3.3.叶子节点3.4.测试 4.分类5.使用场景6.优点 1.概述 &#xff08;1&#xff09;大家对于上面这个图片肯定非常熟悉&#xff0c;上图我们可以看做是一个文件系统&#xff0c;对于这样的结构我们称之为树形结构。在树形结构中可…

JDK并发修改异常的一个“BUG“

很多电商公司早期的架构都是基于PHP&#xff0c;所以我身边会有很多很厉害的PHP老哥&#xff0c;但现在都在写Java。昨天看到他在看Java的并发修改异常&#xff0c;正打算秀一波操作&#xff0c;却被他的一个问题难住了&#xff1a; public class ForeachTest {public static …

【EI会议征稿】第三届区块链、信息技术与智慧金融国际学术会议 (ICBIS2024)

第三届区块链、信息技术与智慧金融国际学术会议 (ICBIS2024) The 3rd International Academic Conference on Blockchain, Information Technology and Smart Finance 第三届区块链、信息技术与智慧金融国际学术会议 (ICBIS2024) 将于2024年2月23-25日在马来西亚举行。本次会…

Java+Spring Cloud +UniApp +MySql智慧工地综合管理云平台源码

智慧工地围绕工程现场人、机、料、法、环及施工过程中质量、安全、进度、成本等各项数据满足工地多角色、多视角的有效监管,实现工程建设管理的降本增效. 智慧工地综合管理云平台源码&#xff0c;PC监管端、项目端&#xff1b;APP监管端、项目端、数据可视化大屏端源码&#xf…

计算机毕业设计 基于SpringBoot的失踪人员信息发布与管理系统的设计与实现 Java实战项目 附源码+文档+视频讲解

博主介绍&#xff1a;✌从事软件开发10年之余&#xff0c;专注于Java技术领域、Python人工智能及数据挖掘、小程序项目开发和Android项目开发等。CSDN、掘金、华为云、InfoQ、阿里云等平台优质作者✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精…

小白看CLIP代码解析

CLIP代码解析 CLIP演示代码&#xff08;以cifar100举例&#xff09;补充11. 为什么选用100*image_feature&#xff1f;2. 为什么使用L2规范点积&#xff0c;而不直接使用点积&#xff1f; cifar100的所有类别model.encode_image >> VisionTransformer补充21. 为什么加入c…