Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2003 Homework 3

Ask questions here!


Is it okay to just put the file path to the canvas or do we need to do the whole getMediaPath thing? For some reason my computer says there isn't a file when I do that. Also, I can't get it to just show the canvas. It will print it, but it won't come up on my screen. Any solutions to this?

You won't lose points for doing the whole file path, but if you can't get getMediaPath to work, you should work at it. You really want it working before you get to homeworks 4 and 5. If you get an error that it isn't a file, you have the filename spelled wrong or you're missing the extension. What does it say when you print it? Mark Guzdial


I actually got the canvas to come up finally, and I'm working on the MediaPath. Thanks!

ok person who couldnt get getmediapath to work, how did you finally get it to work. when i try to put it in my function it says that it cant find the file. this is what i said in my function
flow=getMediaPath("flower2.jpg")
and this is what it returns when the functions fails
Note: There is no file at C:\jython\jython-2.1\jes-ncflower.jpg
C:\jython\jython-2.1\jes-ncflower.jpg
makePicture(filename): There is no file at C:\jython\jython-2.1\jes-ncflower.jpg
An error occurred attempting to pass an argument to a function.
it seems like its not looking in the mediasources folder for some reason because the actual file path is
C:\jython\jython-2.1\jes-nc\mediasources\flower.jpg
and i copied the file to the folder jes-nc, the last place the computer looks, but it still cant find the file
its there - HELP people! im stuck
ps, it cant find the 7inx95in canvas either

do we have to fill the whole canvas or just put the three pictures on there

is the canvas 7inx9.5in or 7inx95in ?

79.5

7x9.5

am i suppose to create a canvas 7x9.5 or its already in mediasources? the only one i saw there is 7x95

7x95 is the 7inch by 9.5 inch canvas. No, you don't have to fill the whole thing.
As you get your collages, consider posting them in the Sp2003 HW3 Collages Mark Guzdial


For the person who can't get getMediaPath() to work – did you remember to setMediaFolder() first? Mark Guzdial


So for this assignment can we just use the flowers in the mediasources file and do somthing similar to the example in the book and the lecture slides?

I know we can rotate a picture couter-clockwise once because that is shown in the lecture slides. But is there any way to rotate the picture the other way or turn the picture upside down?

Yes, you can just use flowers if you want. But you're also encouraged to be creative and build cool things, too! REMOVEDre, you know how to turn a picture upside down – read the mirroring examples again! You can probably figure out how to go clockwise too. Mark Guzdial

If we collaborate with someone, can we turn in the same exact program, pictures, etc.?
Yes, but I encourage you to try to use your own pictures. It's not necessary, but you'll get REMOVED out of it that way. Mark Guzdial

OK, so I made my collage and I would like to just save the product of running the program as a picture or somthing to keep on my computer. How do I do this? - REMOVEDsan Holloman
writePictureTo(picture,"filename.jpg") Mark Guzdial

How do we save a copy of the collage to turn in? Thanks
See above. This is also available in JES Help, and in lecture slides, and in the book. Mark Guzdial

I understand that we have to writePictureTo, but I can't figure out what to input as the picture and filename. I've tried everything but can't get it to work.

If you write your collage function so that it returns the canvas when you're done, you can assign a name to the returned value (canvas = collage()). You can then write out the collage with writePictureTo(canvas,"mypicture.jpg"). If you're still getting errors, post the error. Mark Guzdial


I'm not getting any errors to save my picture, but I can't find where it is on my computer...any ideas?
What filename did you use? If you didn't specify a full path, it's in your JES (or jes-nc) directory. Mark Guzdial

Ok, I have the collage working (or at least I think I do), but I can only see the top of one of the pictures! The rest are too far down on the canvas to see! Can anybody tel me how to see the bottom of the canvas please? Student117

Write it out, then double-click on it in Windows. You should be able to see it in IE or Netscape. Mark Guzdial

One REMOVED question–do all of our pictures in the collage need to be touching exactly? (or can some of them have space between them) BTW–I used the other size canvas to view the collage and then I will just change it to the other when I turn it in I guess. Student117


Entirely up to you. You'll notice that the two collages currently on the gallery do it differently: One has none touching, the other has lots of overlap. (Both are REALLY cool!) Mark Guzdial


I'm having trouble saving mine as well... i had the code show and return canvas so i added this line to save it as a picture, but it definately is not showing up in the jes directory.... writePictureTo(canvas,"/Users/kristief/jes/mediasources/KristiesCollage.jpg") am i doing something wrong? Student68

nevermind! i figured it out! =) Student68

Is it ok if I let the program randomly choose what image alteration to do? I'm going to try and write the program so it takes in the picture and place it within the canvas three times, using random alterations for each copy. Is that too out of line with the assignment or just a waste of time?

David Petersen

OK Dr. Guzdial, I finished mine and I was going to upload it onto the page just for you (even though it's not quite as exciting as some of the others), but then when I tried it asked me for a username and password and I couldn't figure out what mine was (I don't remember ever making a password for this site?)! Student117

I used this code writePictureTo(canvas,"/mediasources/mycollage.jpg") and I can't find it either.

REMOVEDmmer, read earlier on this page: Username attach password carmen. Look for the mediasources directory on your disk and you should find mycollage.jpg in there. Mark Guzdial


It's not in my mediasources folder.
Not your normal one. Because you said "/mediasources/mycollage.jpg" then it's in the directory "mediasources" on your hard disk, not in your account – if that directory exists. If it didn't, then it may not have saved at all. Try just "mycollage.jpg" without the directory, then check your JES folder. Mark Guzdial

So all we have to do is use the writePictureTo function and it should be in that directory.
It should be in your JES directory. Mark Guzdial


So if none of these things work what should I do now?

None of which things? You could try doing a search for the file you created. In Windows, go to your Start menu and choose Search. On Macs, go to the Finder and find Search in the Edit menu (I think...I miss my Powerbook!). Mark Guzdial


OK... I have played with this thing for days now and am stuck. I keep getting this error message:
" The error java.lang.ArrayIndexOutOfBoundsException has occured "

Is this because maybe I am trying to use a picture that is too wide or tall? I really am stuck... I have looked at the code off the create a collage page...and it works when I use the flowers, but when I start using my own pictures.... I am getting no where.

And it says this line is the error
"cx=getPixel(canvas, targetX , targetY)"

But that is straight from the notes. Help???
Student86

Justin, check your targetX and targetY values – they're beyond the height and width of your picture. (We had this in lecture once, and I put print statements before that line, then saw the values when it stopped.) When you use your own pictures, you'll have to adjust the ranges to fit for the new pictures. Mark Guzdial


Okay, I can't find my picture anyway and I've run sooo many searches...this is my code:
return(canvas)
canvas= collage()
writePictureTo(canvas, "/mediasources/mypicture.jpg")
I've also tried just writePictureTo (canvas, "mypicture.jpg") and that doesn't work either...what am I doign wrong?

anywhereError: this should not happen not anyway ;-)
That's directly from your method? You're never calling collage() and you're never writing the picture out. When a function executes return, it's DONE – nothing else in the function executes! You need to do canvas=collage() and then the writePictureTo from the COMMAND area, not from your program. Mark Guzdial

I keep getting errors for this statement
for sourceY in range(1,getHeight(picture)):
yes, it is indented right, etc, I really dont konw what is wrong with it.
sarah cormack

oops and i guess i forgot how to put my name as a link too :)
Sarah, print sourceY and show(picture) on the line before to see what happens and what those values are. What error are you getting? Mark Guzdial

I really dont know what went wrong, I left, came back and it worked? oh well i geuss thats all that matters.
Sarah Cormack


I don't know what I'm doing wrong. In the command area I wrote canvas=createCollage(), then writePictureTo(canvas,"mycollage.jpg") and I can't find it anywhere. Even when I search I can not find it.

Do a show(canvas) before you write it, to make sure that the picture was generated. If nothing was generated, nothing will be written. Mark Guzdial


It was generated it shows up, but I still can't find it.
Try a path then. If you setMediaFolder(), then writePictureTo(canvas,getMediaPath("mycollage.jpg")) should put it in your MediaFolder Mark Guzdial

I'm also trying to save my picture.
If I do writePictureTo(canvas,"mypic.jpg"), I get the error: A local or global name could not be found.
If I do write PictureTo(collage,"mypic.jpg"), I get the error: Input is not a picture, can't pass an arguement into a function.
I've tried reloading and restarting Jes, does anyone know what this means?
Is canvas a variable in your command area or in your function? Is collage? Try showing it first – if it doesn't show, it's not the right variable name. Mark Guzdial

Nevermind the above question, I had the spacing wrong on the canvas = collage()and I guess that was making it show an error.


Is it ok if the pictures overlap? I got all the pictures to copy onto the same canvas, but the slightly overlap.
No problem at all. Mark Guzdial

ok it will not save my collage. I am typing, writePictureTo(canvas,"mycollage.jpg") and it keeps telling me a local or global name can't be found. HELP!
That means that canvas is not the name of the picture containing your collage. Try printing it or showing it. Are you returning the canvas from your function? Are you setting a name to it? Mark Guzdial

My program loads fine without error, but when i try to run it...I get this line

>>> createCollage()
Picture, filename C:\Documents and Settings\Default\Desktop\CS1315\mediasources\7inX95in.jpg height 684 width 504
A local or global name could not be found.
Please check line 53 of C:\Documents and Settings\Default\Desktop\CS1315\Programs\HW3

What am I doing wrong. Also, my JES is shutting off after I try to my programs. :( I just want to get it done...
Purposely blank
The error means that there is an error in your createCollage() where you're using the wrong variable name. Check the spelling. If you turn the Options mode to Expert, it will tell you the name of the variable that it can't figure out. What line is yellowed? That should be where the invalid name is. I don't know what it means that JES is shutting off after you try your programs? It quits? There is a function named sys.exit() that if you execute it, it will quit JES, but I can't imagine you doing that on accident. What exactly happens? Mark Guzdial


So how do I save my collage and turn it in.

this is a nightmare!! i finally got it to work... but i CANNOT get it to save... how many pts do we get taken off if we dont send that in... mine will not save!

me too

JES exits when I try to load it. Its really odd. It has never done this before. I even restarted my computer. What happens is I get this message on the black screen that comes up behind the part where we type in our program and commands. I press save then load and the computer acts like it is 'thinking' then it exits with a message on the other black screen. It is so brief that I can't read what it is saying.

I am just going to go to a friend in the class and try it there. Let me know if you have heard of anything like this happening.Purposely blank

My code works, can I just turn in my code and the original image and the ta can run the program and see the collage for himself. Because I used pictures in mediasources.

My code works, can I just turn in my code and the original image and the ta can run the program and see the collage for himself. Because I used pictures in mediasources.



me too, i CANNOT get the thing to save...i'm also wondering how many points off it is to just turn it in as is???

Can somebody please help I just told my friend to do the same thing I was doing to write it out and her's worked. I'm lost.

I have a question. In the homework description it says "shifting or altering colors of the image." So does that mean that "shift" refers to the colors? Or can shift mean shifting the picture? Would it be okay if I had the right number of images and just flipped one sideways? Does that fit the requirements? Student121

MINE WONT SAVE! ROOOOOOAR!

Can a TA or someone please help!


If you can't get it to save, one of the things that might be wrong is your path. If in doubt, just explicitly save it to C:\. Also, make sure that the picture you're trying to save is the right one:
>>> pic = makeCollage()
>>> writePictureTo(pic, "C:\\myCollage.jpg") #Yes, that's two \'s
Student57|

Good job Adam. He's the number 1 TA.

Remember to change the name of your file to something unique before you upload to the gallery. If you name your collage "myCollage.jpg", and somebody else uses the same name and uploads, it will replace the original. All of a sudden, your collage right by your name will be replaced with the new one. Oh no! Student57


how did the season spring get it's name.



Link to this Page