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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2006 Homework 3 questions page

Ask your questions here...

Uh.... is addOval even a function? JES says no:
"No entry found for 'addOval'"

You're right, it isn't a function. It's a method. But it's there, trust me. (page 328 of the textbook) -Blake O'Hare

Do we have to use walking in our movie? Can our animation be of jumping or swimming or something like that?

As long as it's some sort of n-framed motion sequence, it will suffice. -Blake O'Hare

For the homework since we need 50 frames do we have to take 50 pictures of someone walking slowly by slowly? Also what exactly is mod?

You are supposed to use only a couple pictures of a person walking looping over and over for the 50 frames. Mod is remainder. If you have 4 pictures called person0.jpg, person1.jpg, person2.jpg, person3.jpg, then you would use person(frame number mod 4).jpg as the picture to copy. For example, on frame 27 you would use person3.jpg because 27 / 4 has a remainder of 3. On frame 28, you would use person0.jpg because 28 / 4 has a remainder of 0. -Blake O'Hare

Is our walking object supposed to move across the screen or walk in place?
Your object should walk across the screen. -Albert d'Heurle


How is it exactly that we can loop with different pictures as input? How would the program differ compared to looping only one picture multiple times across the screen?
The figure would just slide across in that case. (I suppose that would look ok if the figure were a skater). Using different pictures will give the impression that the figure is going through a walking motion. Colin Potts

Is our function supposed to just make the sequence of frames or actually make it into a movie?
Everybody should check that their submission meets the items in the checklist on the Homework 3 page. Two of the items are as follows: (1) Your function takes in a directory, (2) Your function outputs frames to that directory. Colin Potts

JES also doesn't seem to recognize what "mod" does. Are you just using this to describe the method that we should use, or is this a command / function that JES should undertand. If you are just indicating the method by which we should loop the image, is there any chance you could elaborate on what the code would look like that does this, because I can't seem to find any in the book.

Thanks alot.

Mod is denoted by the % symbol. This will be gone over during recitation this week. -Blake O'Hare

How do you program loops that can use multiple pictures multiple times, like using pictures 1-5 and then using them again and again until reaching frame 50?
The mod function should be discussed in recitation. Liz Helms

Do you ever get the feeling that roast beef is the most delicious food?
no. Liz Helms

I have my program written for the walking part and I want to see if it works. When I look in my directory all of the frames are in the folder and look in correct order. When I click on a frame it pulls it up in my photoshop automatically. I tried to use mediaTools but couldn't find it. How do I go about using that to view that everythings working??
The Media Tools tab will only display pictures that you have loaded or manipulated in the command area of JES, i.e.: >>> picture = makePicture(pickAFile()) etc. If you want to see all your pictures go together like a real movie, google a movie maker program that will take all your frames and put them together smoothly. Thats all that I know of that will let you view them like that... Liz Helms
Mediatools can do this, but it is a bit flakey. In Mediatools, select the VideoTools panel. A blue widget will appear with buttons 'Open' 'Menu' 'Windows' etc. Click 'Menu'. In the drop-down menu that now appears, select the bottom item ('Create JPEG movie from folder of frames'). Another drop-down menu appears, this time containing files and directories. You should be able to work out how to navigate to the folder containing your JPEGs. Select the FIRST frame in the sequence you want to view as a movie and MediaTools will add the rest of the files one after another automatically. In the sequence of pop-ups that now appear, give your movie a name, select a quality level (too high may cause you to run out of memory: I use 50 in class, and it always works, although a bit low-resolution), and a frame rate (16 fps should do it). You will then see your movie run before your very eyes, and it should be saved in a .jmv file. Remember that to run Mediatools in the first place, you drag the Mediatools icon onto the SqueakVM icon. Double clicking on the Mediatools icon probably won't work. Colin Potts

I used MediaTools and it only showed 36 of my 50 frames, is this just a MediaTools thing b/c I have all 50 frames in the directory ???
Nothing would surprise me! But, I can't reproduce this behavior (Can anybody else?) so I am at a loss. Maybe you missed out the leading zeroes and that is throwing MediaTools? Or maybe the final fourteen frames are the same as number 36, so you're seeing no changes? Colin Potts

how do we get different color text?
Look up addTextWithStyle in the index of your book. -Blake O'Hare

how would you take your slides halfway through and get a different set of picture to mod for the rest of the frames?
Use an if statement.
if frame <= some number:
  do something
if frame > some number:
  do something else.
-Blake O'Hare

How does moviemaker work? When i click on it there is a black box that appears, and a selection window to pick the first and last frame, but when i choose some error message pops up in the black box. In the question above someting about video tools is mentioned but none of that is on there. and if we have to google it what do we google for? and how do we use it?
My advice is NOT to use MovieMaker. I can't get it to work on the Mac, and apparently it crashes regularly on the PC. My recommendation above is to use MediaTools, which is a completely different program. Liz's advice about googling is if you want to look on the web for free or commercial media tools. That shouldn't be necessary unless you want production-quality software. Mediatools is clunky, but it does work. Colin Potts

yeah but how do you use media tools? the book doesnt explain anything and we didnt do it in class without the squeak program
I explained it above. Instead of complaining that you don't understand, read my advice carefully and follow it. (MediaTools is a Squeak program.) If you are still confused then, wait until class tomorrow and I will demonstrate MediaTools in class then. Colin Potts

I used MediaTools to run my program and it ran fine but it runs really quickly through the 60 frames I have, I tried to change the frame rate to 8 and it still ran really quickly. Is this okay or do we need more frames??
We will only be checking to see if your program generates a bunch of JPEGs. Actual animation is up to you. -Blake O'Hare

def writeFrame(dir,pic,frame):
  framenum= str(frame)
  if frame < 10:
    writePictureTo(pic, dir+"/frame0"+framenum+".jpg")
  if frame >= 10:
    writePictureTo(pic, dir+"/frame"+framenum+".jpg")


i keep getting the error:
An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.
Well, your code looks perfect, which means the problem must be earlier. Are you sure you're passing your 3 parameters in your other function in the same order that you have them written in the def statement? -Blake O'Hare

Had a minor problem not worth seeing a T.A. about, but still frustrating. Should I change the canvas color so that the text shows up? Is that what is happening when i can't see my guy say ouch?
The default addText function makes black text. If your background is black, then yes, that is the problem. You can either change the color of the background, or you can use the addTextWithStyle method which allows you to add text with different color/font/size. -Blake O'Hare

... when I use writeFrame(x,x,x) it is of course in the same order. could it be a problem with 'dir' since it is just used as a vairable but never really defined.
When you definded your annimation fucntion did you use dir so annimation(dir) or did you directory so annimation(directory) -Albert d'Heurle

most definately (dir)
How are you defining what dir is? I think the easiest way is to say dir = pickAFolder() and then navigate to where you want the images created. -Albert d'Heurle

ive tried several different ways to set the frame... no matter what function I am using it has trouble with the line >>>> writePictureTo(pic, dir+"/frame0"+framenum+".jpg") when I am trying to write the frame.

You're not alone. Are you sure that you have set dir to a directory? Try to get this to work by leaving dir off (i.e. writePictureTo(pic, "/frame0"+framenum+".jpg") and see whether that works. This will write the files to the wrong directory of course, but if it works, you know you are passing in the wrong value of dir to the function that calls writePictureTo() Colin Potts

When I try and load my program I get the error "Input is not a picture." I am pretty sure that it is a picture–jpg. I tried using other pictures and the same error occured. What am I doing wrong?
Are you sure you that the input is a picture and not a file containing a picture? (I.e. Did you forget to makePicture() it?) Colin Potts

where do you download mediatools besides the picture and sound tools? is that the same as media sources?

MediaTools is on the CD included with the textbook. I'm not sure why it is not available for download. Media sources is something different: it is the folder containing all the example pictures and sounds. Colin Potts
You can now download Media Tools from this link Media Tools -Albert d'Heurle

well, i tested as above and it definately is a problem with my value of directory. is there a way to figure out what my input fir writePictureTo() should be. because what I thought was obvious is not working.
can we see your code to write the picture to the computer -Albert d'Heurle

Is doing chromakey really worth the extra credit? I am running my program with it enabled and it I still havent even gotten my first frame written to the directory after 40 minutes... if I comment it out, the program takes like 10 minutes to write all the frames...
Are you sure your chromakey code is correct. That seems like a long time to run the code -Albert d'Heurle

Are you having the program running chromakey on every frame? That could be the problem. My code was doing that too, and I think that was what was happening. Make sure the chromakey is outside of the for loop. I screwed that up.
This is wrong. If your code takes more than a few minutes to run, there is something wrong with the layout of your code and you are possibly double-nesting for loops where they shouldn't be. But in order for chromakey to work, it needs to be done every frame. -Blake O'Hare

any sprites I save to my computer are saved as PNG files, not JPEG files; how do I get around this?
That's fine. JES can read 2 kind of picture file types: .jpg and .PNG. Remember that these things tend to be case sensitive. -Albert d'Heurle

how do we set the directry so that the writePictureTo(canvas, directory+"//frame"+framenum+".jpg") works?
That's what your directory variable is for. It's what you pass into your function. -Blake O'Hare

writePictureTo(pic, folder + '\frame0’ + frameNumber + “.jpg”)
UPDATE TO THIS QUESTION: I changed the ""s to ''s and that error went away, but now I'm getting the same error two lines down for the line:
writePictureTo(pic, folder + '\frame’ + frameNumber + '.jpg')
Never use a \ by itself in a string. Use \\ if you want a backslash character, or // if you're using it for a directory delimiter. -Blake O'Hare


Really broad question...I've written all my code and I'm getting a "Your code contains at least one syntax error, meaning it is not legal jython" error. What kind of errors should I be looking for?

Look for missing quotation marks, closing/opening parenthesis, colons, etc. -Blake O'Hare

My code, which I'm pretty sure is correct, will not load because it keeps telling me that I have a spacing error in the program. I checked the line it specified and the one before at least 15 times, I also got some other people to look at it as well, and we can't seem to find a problem in my code, what could possibly be wrong to give me that error?
Spacing errors can be tricky. Basically there is a problem with your indentions. Make sure everything is indented the same way throughout your code. i.e. you used all tab spacing and in one spot you used one space spacing. -Albert d'Heurle

alright, I redid all the indentations, checked over everything,and it is still giving me a line spacing error, but now its in a different place, nobody can figure out what is wrong with it. I don't know what to do, if my code doesn't work I'll fail this assignment, and I know this code will work. What in the world do I do?
Can you go to a TA's office hours? -Albert d'Heurle

this is for Tia(Blake told me to ask you about these specifics): it says that they are to be saved as jpegs, are pngs ok? and my walking person does not DIRECTLY interact with the text i added. they are supposed to interact and they sort of do...when the person runs into something, some part of the background says the text. if you need to see it to make decisions, let me know. thanks, Janelle

I would recommend you email her....it might be a better method of communication than via the questions page. Liz Helms


I'm having directory problems. When I input the directory of the picture files into the function, I used getMediaPath(directory) to change the media path, but the program does not recognize whats going on.

When I type in: "animation("C:/samus/")"
I get this: "Note: There is no file at C:\JES\C:/samus/"

The makePicture() function that chooses which frame to get for each iteration is able to make the pictures fine, but for some reason some error is occuring inside my code which hinders it to make frames.

getMediaPath takes in a filename and looks for that filename in the mediasources. It will then return a full path to that file. For example:
 >>>getMediaPath('boot.jpg')
>>>C:\Documents and Settings\Larry\My Documents\cs1315\JES\boot.jpg
What you are more interested in is probably setMediaPath. Use that inside the command window. That will open a chooser to let you select a directory. Then you can use getMediaPath("myPicture.jpg") to actually get access to the picture you want. Larry Olson  


When I write out my copy function I keep getting the java.lang.ArrayIndexOutOfBoundsException error for any sourceY value greater than 1. I was just wondering what this is exactly and how I would go about fixing it.
Typically, this means that you are trying to access a pixel that is outside the picture. For example: A pixel located at 150,150 is NOT going to be in a 100X100 picture. Likely you are passing large destination values into your copy function. The values are likely so large that as soon as 1 is added to them, you are going out of bounds. Larry Olson


Can someone please explain mod? Thanks!
Mod is the % sign. It returns the remainder after division. Example 5%2 = 1, 6%2 = 0, 5%3 = 2, 6%3 = 0, 7%3 = 1 etc. Larry Olson

For some reason when I set my directory to where the pictures are I get an error and I need to put the picture in the same file that JES is in. However, it still writes the pictures to the directory
that I define directory as. What could be the problem?
JES typically looks for pictures inside its own path. Therefore, unless you are explicity using the directory you pass in to open the pictures you need for your movie, then it will looks there. Perhaps you could try setMediaPath() ? Larry Olson

I keep getting the following error for the line below: An attempt was made to call a function with a parameter of an invalid type. This means that you did something such as trying to pass a string to a method that is expecting an integer.
    if frame<10:
      writePictureTo(background,directory+"//frame0"+framenum+".jpg")

make sure that you have converted framenum to a string using the str() function. Larry Olson


Is the directory the same thing as the media path? in other words, should our function write the new frames to the same folder that the background and other images are in?

no, mediaPath and the directory are not the same thing. Amanda Bennett

Would it be possible to see an example of what we're supposed to create (like how we got to see a sample collage, etc.)? I had to miss class on the day that an example would have been given.

What will you type in the command area when you grade our homework?

We will type setMediaPath() and pickAFolder() in the command area. Tia Doppenberg

How do you have two pictures as input and program it to make the pictures move across the screen (telling it where on the screen to start) using the pictures alternatively?

This is where the mod function comes in handy. You can use mod with if statements, and in those if statements you can decide which picture to put on to the background. You can use other ways though. Tia Doppenberg

ok for walking is it ok if the person is using a forward roll as a means of like.. walking? like she does this roll thing but it's to move to a different place. would you consider that walking?
Yes, that's fine. Someone else is using swimming. As long as the figure doesn't slide .... i.e. there is a difference in appearance – leg or arm position, or orientation – from frame to frame. Colin Potts

I can't figure out how to make the person walk...how do you determine the source X and source Y for the following? Also, if I want to y to stay the same and only the x to grow as the grame grows, how do I do that?
sourceX = 45
for targetX in range(frame3,frame3+((200-45)/2)):
sourceY = 25
for targetY in range(frame3,frame3+((200-25)/2)):
color = getColor(getPixel(barb,int(sourceX),int(sourceY)))
setColor(getPixel(canvas,targetX,targetY), color)
sourceY = sourceY + 2
sourceX = sourceX + 2


i believe my code is correct for everthing because the pictures are created however it does not move across the screen. i believe it has something do with my copy function but i cannot figure what.

I don't understand your problem. What isn't moving across the screen? Are you saying that all your pictures are identical? Colin Potts

my pictures will not show up in the program. I don't understand what I am doing wrong. what do we use as the sourceX and sourceY? I am also getting an error with the color=getColor(getPixel(walk1,int(sourceX),int(sourceY))). Is there anything wrong with this? I have used it previously in my program and that one works just fine.

I'm getting " The error java.lang.ClassFormatError has occured" ...what does that mean?

When I try to run my code, it gives me:
I wasn't able to do what you wanted.
The error java.lang.ArrayIndexOutOfBoundsException has occured

Before, everything was workig until frame 16(very arbitrary, seeing as how i never cut off at 16) and told me to check the copy function. I changed the copy function and now I keep getting that error.



Links to this Page