![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| All assignments are due at 5:00p.m. the day they are due unless otherwise specified. |
| Dont worry about that, we will overwrite the mediapaths so that they refer to the proper places. Just be sure to turn in your pictures with your assignement. Larry Olson |
| Yes that's okay. The entire canvas does not need to be covered as long as there is an image in each of the four quadrants. Nicole Seekely |
One way of cropping a picture is just to specify the pixels that you want copied in the range for the x and/or why loop. For example, if you wanted to crop off the left 25 columns of pixels, you would do something like:for sourceX in range(26, getWidth(pic)+1):However, you would need to do that every time you copy the picture onto the cavas. See Slide 25 from May 28th lecture. Otherwise, you can crop the actual image using JES in the same fashion and then save it using the writePictureTo function. Nicole Seekely |
| Sorry – I have already corrected that for the Fall version of the book. Mark Guzdial |
| Are you sure that you have previously defined each of those variables that you used (i.e. canvas, targetX,targetY, AND color)? If that's not the case, then maybe post some more of your code so we can figure out what's wrong. Nicole Seekely |
| If I understand what you're asking correctly, you should have at least ONE original and/or altered picture in each of the four quadrants OF THE CANVAS. So the basic requirement would be to have the original picture in quadrant1 of the canvas, then an altered picture in quadrant 2 of the canvas, an altered in quadrant 3, and an altered in quadrant 4. Hope that clarifies it! Nicole Seekely |
| To answer both those questions... the writePictureTo is used at the end of your code/function. (It would be in a spot such as where you would put repaint(picture) or something of the sort.) So after you're done manipulating the picture, you insert writePictureTo(picture,location). This saves the manipulated picture to your computer. Be careful with the variable "picture" - for this assignment, you would most likely be putting "canvas" or whatever you named your canvas as since that is the final image you want. For location, you can either put the direct path and filename such as r"C:/JES/mediasources/hw2.jpg" or you can just put "hw2.jpg". Nicole Seekely |
| Okay, so you're getting an Out of Bounds error which means JES is telling you you're trying to access pixels that don't exist. It looks like you're trying to copy a picture into the top right quadrant? There's only about 500 pixels give or take a few width-wise in the canvas. So if your picture is greater than 500 minus 280 wide, you'll be copying pixels beyond the existence of the canvas. So maybe try setting your targetX to a smaller number and see if it works. Let me know if this is the problem or not! Nicole Seekely |
| All ya gotta do is change the targetX and targetY for each picture to get them to change position. For example, to place the picture in the first quadrant, you would set targetX and targetY = 1, to place in the second quadrant, target X=250, targetY=1; to place in third quadrant, targetX=1 targetY=350, and so on. Just basically, the more you want the picture to move down or over, the higher the target values. Just be sure that your picture doesn't run off the canvas because then you'll get an out of bounds error. Nicole Seekely |
| Really, it could be either. Most likely it is the code though. Larry Olson |
| Good question, email me your code or post it here. Alternately, visit a TA in office hours Larry Olson |
| There is a reason it isnt there. You have placed your writePictureTo() function below a return. When the computer sees a return it immediately thinks "Ok, Im done, there must not be anything beyond this, Im going to give control back to the user along with anything else ive been working on". In this case, you are regaining control of the computer and you are getting your canvas back. The computer never even executes the writePictureTo statement. Larry Olson |