Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Task 2 was to make a scene using the shapes we made. I decided to fill the shapes I made in, which involved giving the turtle slightly different instructions. Since the fill function only works on flat objects, I had to treat each face of the shape as its own part to fill, meaning I couldn't take a shortcut to draw the shape, and had to have overlapping edges sometimes since the shapes shared them. At any rate, instead of drawing the main face(s) of a shape and then connecting that to the rest of the shape, I now had to do everything individually. Then I made the scene by arranging the shapes a certain way. The trees were stacked pyramids, for example, and their trunks were stacked blocks. The grass was just randomly scattered upright triangular prisms. The code below shows how first the shape is created, then the color is set, and then it is drawn at the specified location-- and we needed to input a z coordinate as well this time. There are 200 "grass blades" in total, since there are 20 drawn ten times. Every blade was randomly placed using random.randint with the desired range on the x and y axes input. Also worth noting is that I made the driveway by drawing a flat rectangle multiple times with the z coordinate being one more each time, giving the illusion of thickness. 


For Task 3, we needed to improve our code in some way, including doing one of the extensions, so I did extension 7, which was to make another "shape" that was actually a dynamic shape, drawing whatever the file it reads says, and, optionally, what the user inputs in the terminal. I didn't need to change the parent Shape class at all, I just needed to give this dynamic shape class instructions to read the file that was passed in in its init function, or to write the argv into another file (or possibly the same, depending on what is given) if it is given and read that instead. Then, once the parent init function is called, the only difference is that the string passed in is the string read from the file. This code is shown below:
This "argv" is passed in through whatever line of code is calling the shape to be made; for example, the next pictures show what code I input in a file and into the command line to draw the picture below it. I wrote into the command line the two shapes that I wanted to be drawn. The place the yellow shape expects to get its text from is the first index of the command line, and the blue one expects it from index two. If the command line is not to be used, the argv should be given the value of None instead, so the file will just be read instead.

...

I also did Extension 4, which was to make another scene. It is not a "scene" per se, but I made a sword object by arranging objects from my shapes library in a certain way. The tip of the sword was the same 3D shape I used for my grass blades in the first scene; the blade was four sets of flat rectangles stacked on the z axis through a for loop to make it appear to have depth; the guard was a 3D rectangle object I createdalso stacked rectangles; the hilt was a lot of stacked cubeseight stacked rectangular prisms; the pommel was a bigger big cube. I also added some jewels along the hilt and pommel, made from my pyramid shape. Making it was a similar process to the first scene, but I had to be a lot more careful with the arrangement in this.

...