- /
- 
        Growing City over years..
        on 28 Nov 2023
        
        
 
    - 16
- 23
- 1
- 0
- 1334
drawframe(1);
 Write your drawframe function below
function drawframe(f)
rng(2,"twister")
numRows = 15;
numCols = 15;
cuboidWidth = 1;
cuboidDepth = rand();
figure;
for row = 1:numRows
    for col = 1:numCols
        xPos = col * (cuboidWidth + 0.2);
        yPos = row * (cuboidDepth + 0.2);  
        zPos = 0;
        cuboidHeight = rand();
        vertices = [
            xPos, yPos, zPos;          
            xPos + cuboidWidth, yPos, zPos;           
            xPos + cuboidWidth, yPos + cuboidDepth, zPos;           
            xPos, yPos + cuboidDepth, zPos;          
            xPos, yPos, zPos + cuboidHeight+f/100;          
            xPos + cuboidWidth, yPos, zPos + cuboidHeight+f/100;          
            xPos + cuboidWidth, yPos + cuboidDepth, zPos + cuboidHeight+f/100;           
            xPos, yPos + cuboidDepth, zPos + cuboidHeight+f/100;           
        ];
        faces = [
            1, 2, 3, 4; 
            5, 6, 7, 8; 
            1, 5, 8, 4; 
            2, 6, 7, 3; 
            1, 2, 6, 5; 
            3, 4, 8, 7; 
        ];
     buildingColors = [
            0.6, 0.8, 1.0; 
            1.0, 0.8, 0.6; 
            0.7, 0.7, 0.7;
            1, 0.8, 0.8;
              1, 1, 0.8;
            0.8, 1, 0.8];
       Colors = buildingColors(mod(row-1, size(buildingColors, 1)) + 1, :);
        patch('Vertices', vertices, 'Faces', faces, 'FaceColor', Colors, 'EdgeColor', 'k');
    end
end
streetWidth = 0.2;
for row = 1:numRows + 1
    for col = 1:numCols
        xPos = col * (cuboidWidth + 0.2);
        yPos = row * (cuboidDepth + 0.2) - streetWidth/2;
        zPos = 0;
        streetVertices = [
            xPos, yPos, zPos;           
            xPos + cuboidWidth, yPos, zPos;           
            xPos + cuboidWidth, yPos + streetWidth, zPos;           
            xPos, yPos + streetWidth, zPos;           
        ];
        streetFaces = [
            1, 2, 3, 4; 
        ];
        patch('Vertices', streetVertices, 'Faces', streetFaces, 'FaceColor', [0.5, 0.5, 0.5], 'EdgeColor', 'k');
    end
end
axis equal;
axis off
grid on;
view(3); 
rotate3d on; 
zoom(2);
end


 

 
            
             
             
              