// Demo nesting for csc220 assn4 NestingCSC220Fall2023PShape // NestingCSC220Fall2023PShape adds rotated framed images in 3 dimensions // From Assignment 4 STUDENT B: // STUDENT B 50%: Each student creates their own shape according to handout spec. // You must use 2D shapes only, with copies rotated in X, Y, and Z directions, and // nested to the degree given by global recursionDepth+1. PImage STUDENTIMAGE = null ; PShape STUDENTSHAPE ; int imgwidth, imgheight ; float aspectRatio ; void setup() { size(1100, 900, P3D); frameRate(60); STUDENTIMAGE = loadImage("HikerApr2023.jpg"); imgwidth = STUDENTIMAGE.width ; imgheight = STUDENTIMAGE.height ; aspectRatio = float(imgheight) / imgwidth ; STUDENTSHAPE = createShape(RECT, 0, 0, 400, aspectRatio * 400); STUDENTSHAPE.setTexture(STUDENTIMAGE); // OPTIONAL STUDENTIMAGE.resize(300, round(aspectRatio * 300)); // aspectRatio = 1.0 ; background(255); imageMode(CENTER); shapeMode(CENTER); } void draw() { int recursionDepth = 4 ; push(); translate(width/2, height/2); float scaledown = 1.0 ; for (int depth = 0 ; depth <= recursionDepth ; depth = depth + 1) { push(); // scale(1.0/(depth+1)); scale(scaledown); fill(0); stroke(0); rectMode(CENTER); rect(0, 0, 415, aspectRatio * 415); // image(STUDENTIMAGE, 0, 0, 400, aspectRatio * 400); shape(STUDENTSHAPE, 0, 0, 400, aspectRatio * 400); scaledown *= 0.75 ; pop(); } pop(); }