• Remix
  • Share
  • New Entry

on 14 Oct 2024
  • 9
  • 159
  • 0
  • 0
  • 1766
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent q m ic u e n X o wg R yg yo ap an aj r m1 b2 a1 x y mu x2 x3 M d x4 O
if f == 1
u = @linspace;
e = @rescale;
n = @normpdf;
r = @randperm;
M = @repmat;
O = @round;
d = @rand;
q = 600;
% Initialize building heights and positions to zero
m = zeros(1, q);
% Randomly assign some x positions "building" structures
building_pos = r(q, round(q/5)); % 1/5th of the 'q' will have buildings
% Assign random heights to these positions
m(building_pos) = randi([10, 300], size(building_pos));
% Continue with the same initialization for colors and other properties
ic = .7 * (d(24, 3) - 0.5);
for p = 2:48
ic(:,:,p) = ic(:,:,p-1) + (d(24, 3) - 0.5) / 80;
end
for p = 1:48
ic(:,:,p+48) = ic(:,:,49-p);
end
X = u(-1, 1, q);
o = [-0.5, 0.1, 0.6];
w = .018 * (d(24, 3) .^ 2);
wg(:,1) = w(r(24));
wg(:,2) = w(r(24));
wg(:,3) = w(r(24));
wg(1:2,:) = .33 * ones(2, 3);
R = [.77 .97 .12 1 .16 .59; .12 .97 .18 .98 0.36 0.90; .18 .99 .75 .78 .5 .97];
yg = (d(24, 3) + .3) ./ 2.5;
yg(1:2,:) = [1.6 1 1; 1.2 1 1];
yo = d(24, 3) - .2;
yo(1:2,:,1) = [-.2 .1 .2; -.2 .1 .2];
% Corrected for loop: start from 2 to 48
for p = 2:48
yo(1:2,:,p) = yo(1:2,:,p-1) + .15 * (d(2,3) - .5);
yo(3:end,:,p) = yo(3:end,:,p-1) + .1 * (d(22, 3) - .5);
end
for p = 1:48
yo(1:2,:,p+48) = yo(1:2,:,49-p);
yo(3:end,:,p+48) = yo(3:end,:,49-p) + .1 * (d(22, 3) - .5);
end
ap = [.9, .9, .9];
an = [.25, .3, .35];
aj = d(24, 1) * .08;
a1 = zeros(q);
[y, x] = meshgrid(X, X);
mu = O(d(24, 3) + .3) * 2 - 1;
mu(1:2, :) = ones(2, 3);
x2 = x;
x3 = x;
x4 = x;
for h = 1:q
x2(:,h) = circshift(x(:,h), O(m(h)), 1); % Offset to 'build' shapes vertically as buildings
end
end
for i = 1:3
a = a1;
for j = 1:24
y1 = y * cos(an(i) + aj(j)) + x * sin(an(i) + aj(j));
x1 = y * sin(an(i) + aj(j)) + x * cos(an(i) + aj(j));
a = a + mu(j, i) * (wg(j, i) .^ .7) .* e(n(y1, ic(j, i, f) + o(i), wg(j, i)), 0, 1) .* e(n(x1, yo(j, i, f), yg(j, i)), 0, .5);
end
p1{i} = a .* e((x + 3) .^ .5, .2, 1);
for gy = 1:3
b1(:,:,gy) = x .* R(i, gy) + .05 - (x - .6) .* R(i, gy+3);
end
b2{i} = b1 .* M(e(p1{i}, -.1, ap(i)), 1, 1, 3);
end
m1 = m .* (d(q) * .5 + .3);
fm = M(m1, 1, 1, 3) + b2{1} + b2{2} + b2{3};
fm(M(x2, 1, 1, 3) > .75) = 0;
fm(M(x3, 1, 1, 3) > .75) = 0;
fm(M(x4, 1, 1, 3) > 98) = 0;
image(fm)
camva(4.5)
end
Movie
Audio
Remix Tree