![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Luckily for you, that's exactly what Monday's (2/7) lecture covers, so be sure you're in class and awake. If you can't achieve either of those or just can't wait, take a look at the lecture slides in the course outline. Gabriel Halley |
| Did you "setMediaPath()" first? Greg Leo |
| Correct. Make sure that the *.jpg canvas is in the folder that you path to in setMediaPath(). You should be passing in the mediasources folder...that (blank) picture should be included in the folder pathed to! Amanda Bennett |
| It doesn't matter what order your def's are in as long as they're all not indented. |
| ??? It's kind of hard to evaluate what's going wrong here without seeing your full code (please don't post that). First check your variable spellings where you call the function for the 2nd time and after that the best thing you can probably do is visit a TA's office hours or talk to someone in person who's already done this assignment who can trace your code to see what's up. |
| Are you sure you're repainting it at the end? If you are, then some other sources of the problem could be that you aren't incrementing one of your target variables and it's copying the picture but onto just one pixel so that it doesn't seem like it's doing anything. |
| In the same .py file that your makeCollage() function is in. It doesn't matter if it comes before or after makeCollage() as long as it's there, but it can't be inside your makeCollage() function. |
| It means you tried to access a non-existant pixel. This could have been caused for a variety of reasons. For example, you tried to access pixel 0,0 somewhere in your code. Or perhaps the picture you tried to copy to the canvas spilled over the edge and you tried to access a pixel that was beyond the right or bottom edge of 7inX95.jpg |
| You could try some of the rescaling code from the slides, but whitespace is perfectly acceptable for this assignment. |
| writePictureTo(whatever variable you used for your canvas, getMediaPath("preferably your gtnumber")) Add that line to the end of your code. Since there'll be a zillion posts to the homework 2 gallery, if your file is named something unique, there isn't a chance that you'll overwrite someone else's submission, which would happen if everyone posted a "myCollage.jpg". Since there's a getMediaPath, then it'll write it to the directory that your images are in. |
| Capitalization does matter. You could rename the file to "tank.jpg" but it would just be easier to call getMediaPath("Tank.JPG"). Once you turn in your homework, you need to attach Tank.JPG to your submission so that your TA can use it. When your TA grades, he or she will do setMediaPath to where ever your image is saved on their computer. (if I understand what you're asking) |
| I think you and Blake were talking about two different parts of the filename. If I understand correctly, you're asking whether there's any difference b/w ".jpg" and ".JPG". The answer is no, your computer understands both as the same file type. Your TA's computer probably does as well, so no need to worry. If it becomes an issue, I'm sure you can work it out with your TA. Gabriel Halley |
| You might want to define a function to mirror the canvas, and make sure that in your main function that mirror is the last picture manipulation that you do. It should look a lot like the other things that you've done to the picture, but now you're just going to mirror the canvas, it has nothing to do with the other picture. Amanda Bennett |
| It's hard to tell you what's going on without seeing your code. Check and make sure that your targetX and targetY are doing the correct thing. Make sure that you are copying below a mirrorpoint line too. If you can't trace through your code, IM a TA or take it to office hours or breakout and they will help you out. Amanda Bennett |
| TA Contact Information has a nice chart with all the TAs office hours by day and time. Greg Leo |
| When you mirror the image, the resultant image will be the same size as the original. You will mirror across the center of the picture (either getHeight(pict)/2 or getWidth(pict)/2 or if you are daring, try mirroring along one of the diagonals) Kelly Lyons |
| yup. you are using the same variable for the picture each time you manipulate it. Try calling the picture you want to use one variable name, and each time you pass a function to it, name the picture something else. You will probably end up with 4 different picture variables, but that is okay. It will eliminate your problem. Amanda Bennett |
| well, you could rotate it the first time with that code, and then rotate once more with the same code (that would rotate 180 degrees) or you can figure out how you can change the code so that you will be copying pixels from the top left corner to the bottom right corner, etc, Amanda Bennett |
| A long thin line representing your picture is generally becuase one of your loops didn't increment correctly. This is generally caused by forgetting to increment the targetX or targetY variable at the end of the loop. If the line is vertical, then this means your targetX is not incrementing because for every row it only copied one pixel. It the line is horizonal, this means that your loops only excecuted once for the y loop and that your targetY is not correctly incrementing. Kelly Lyons |
| Use the writePictureTo function that you learned in Lab2 to save it to your computer. And then attach the copy you saved to your turn in. Kelly Lyons |
| You MUST use the getMediaPath command. Since your function is going to internally create at least two pictures, and you do not know those pictures will be on your TAs computer, by using getMediaPath you don't have to worry about that becuase the TA will setMediaPath to wherever the pictures are. If you were to type an explicit path, then your TA would not be able to run your code. Also, if you used pickAFile() then the function would not run without the additional action of finding and getting the correct file. getMediaPath and setMediaPath solve this problem, and all you and your TA to use the same code on two different computers and still be able to run the function without having to pick the file. Kelly Lyons |
| Try looking at the indention of the lines surrounding the targetY=1 line. Sometimes JES will point you to the wrong line when telling you about an error. Kelly Lyons |
| You can put the function to mirror the canvas either after or before your main function. Just make sure that it isn't inside your main function. Then you will call the mirror function from within your main function. You should probably do this right before your show and return. Kelly Lyons |
| Almost, but not quite. writePictureTo takes in the picture you want to save, and the path to save it to. Instead of "flower1.jpg" (The original), you need to have the variable that stores the collage (Because you don't want to write the original picture again). Then, "flower2" is just where you want to save the picture to. If you want it to be on the C: drive (Named how you have it there), you would have: r"C:\flower2.jpg" Alvin Yates |
| What exactly is the error that comes up? Does it come up when you try to load the program? Check through your code again to make sure every loop is indented correctly, and if you still can't find the problem, e-mail your TA or IM one or go to someone's office hours on monday for help. Amanda Bennett |
| You need to setMediaPath() to your mediasources folder. Amanda Bennett |
| White space is fine for this assignment. You can fix that by changing where the line is that you want to mirror across. trace through your code and see if you can figure out how to do that. Amanda Bennett |
| Scale your pictures down. There are examples in the book on how to do this. Amanda Bennett |
| I don't quite understand your question, but it sounds to me like you are having copying issues. Make sure you keep your targetX and TargetY moving with the source pixels. You don't need to mirror anything until the very end. Amanda Bennett |
| Make sure that you put all of the pictures that you want to use in the same file together (my suggestion is the mediaSources folder). JES will look in the folder that you set as the media path when you call getMediaPath() in your recipes. You will not see the pictures when you setMediaPath(), you will just go to the folder that all of the pictures are in. Amanda Bennett |
| What do you mean when you try to open the pictures normally in JES? Set the mediaPath to the folder where your pictures are and then use getMediaPath() to access them. Amanda Bennett |
| That means you are going trying to access a pixel that isn't there. Check out your sourceX and sourceY and make sure that they aren't going off the end of the picture, and check the targetX and targetY and make sure that they are on your canvas. Amanda Bennett |
| You will be copying the 4 pictures to the canvas and modifying them as you copy. You do not need to save them at all. There are a lot of good examples in the book and in the class notes. Greg Leo |
| Try throwing some print statements into your code to see where the error is occurring. You may also want to put a repaint() function within one of the for loops so you can watch as the code copies the picture. Might take a while, but you will get a good idea what is going on. Greg Leo |
| Save the canvas. Greg Leo |
| int is a function that takes in any number and returns just the integer part of it. For example int(1.6)-> 1. Make sure you are passing a number to the int() function. Greg Leo |
| Make sure that you are not doing writePictureTo() after you do return. Once the return statement excecutes, the function ends and nothing after it is executed. Try doing the writePictureTo either in the command area, or before the return statement. Kelly Lyons |