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 Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2003 Homework 5 Questions

Any questions from the new digital filmmakers?


we've tried to run the program in our notes for making barb's head move and it doesn't write out anything. do you have any suggestions? thanks!
It doesn't create any files? What directory did you use for the input? Mark Guzdial

is the goal of the program to just output at least 30 frames with all the moving parts required? does the function include the specifics on fps and length or do you do that in moviemaker?
You decide fps (and given the number of frames, that determines length) when you use MovieMaker. Mark Guzdial

when i ran the movie maker, it created a movie, but when i try to play it, it says i need to choose a program from the web, or from a list. do i need a certain program to play it on? or am i doing something wrong?
Yes, you need QuickTime from http://www.apple.com/quicktime. It's free. Mark Guzdial

The assignment says we can add ovals as drawn objects, but I can't seem to find the function anywhere. Is there really a function to add ovals?
They are object methods. You'll be meeting them this week. Mark Guzdial


In class today you mentioned that we must have three objects in motion at the same time, but the Homework 5 assignment page says only two. Should we listen to what was mentioned in class or what's on the webpage? Thanks!
Web page – that's the real specification. I just forgot. Sorry! Mark Gudial

I have my program running, and the frames are made, but how do i play the movie. I have quicktime, i just can't figure out how to convert from the frames to the movie.

You use MovieMaker to convert the frames to the movie.
Yup! See the link at the top. Mark Guzdial

Can you elaborate on the MovieMaker program? I'm not sure where this is found or how it runs...Thanks.

The MovieMaker program is at the top of this page under tha Hotspots (very last link), and you have to download it and unzip it in order to use it.

so do we just turn in our code and attach the created drawings or do we need to attach a movie file too?
Just the drawings – the TA's can make the movie. But you can upload to the gallery Fall2003 HW5 Movies. Mark Guzdial


My moviemaker is not creating a movie file. I have all of the .jpg files in a folder and a working Quicktime program on my computer. Any suggestions?
Are you getting an error? You can also use the MediaTools application to build a movie file, a .jmv. That'll work, too. There are directions in the book. Mark Guzdial

i used GIF rather that JPG files. is this acceptable? my movie works fine
How did you use JES to create GIF files? You must write a program to generate the frames. Mark Guzdial

i have 75 frames plus 2 pictures = 77 files to attach to turnin =[ !! is there an easier way? can i attach it as one zip file or something
You don't attach the frames, just the input pictures. The TA can run your program to generate the frames. Mark Guzdial


it says "You must use at least one composited image (a JPEG image that you scale (if necesary) and copy into the image)" so what i mean by i used GIF rather than JPG files is that my images i copied onto the canvas were GIFs.
Aah – right. It's undocumented, but it's true that JES can generally read GIFs with makePicture(). Sure, sounds good. thanks! Mark Guzdial

The way the assignment is written, it sounds like you have to include the frames the program generates for turnin. But if you say not... Good, I wasn't looking forward to attaching all those.
nope, don't attach all the frames. The TAs aren't looking forward to downloading all the frames either =) Angela Liang
And I'll fix the assignment writeup. Mark Guzdial

I just made a little drawing in Paint and saved it as a "jpg" file. Can I use that as my background? I just want to be sure!
yes, that's fine. Angela Liang

Can someone post what they have so far- i need help
There are already two movies up at Fall2003 HW5 Movies. Mark Guzdial

I tried to run some of these problems like tickertape and moveahead but I seem to get an error right away. JES can't load the image even the 640x480.jpg. Need help
Did you set the media path first? Mark Guzdial

You use the addRect command when you want to add a rectangle, and you would normally use the copy picture functio to get a picture on a canvas, but I'm having difficulty getting one picture to post on top of another picture that is a canvas. Any pointers?
What kind of "difficulty"? Errors? Like what? Mark Guzdial


yes. i set the media path first. i tried different jpgs. won't load up the image
Can you open the picture with makePicture and show from the command area? If you can't open it from there, then you have a problem with your JES. Mark Guzdial

Ok, I keep getting an error that reads:
writePictureTo(pict,filename): Path is not valid
An error occurred attempting to pass an argument to a function.

This is the line of code that is highlighted:
writePictureTo(framepict,directory+"//frame0"+framenum+".jpg")
The directory was named. Any hints? Thanks.
Your directory is incorrect. Did you create it first? Mark Guzdial



I completely replaced JES prog. I typed in setMediaPath() and selected the directory I wanted. Then, I typed canvas=makePicture(getMediaPath("rainbow.jpg")). I get the same error msg. load image failed. Was unable to load the image in E:\JES\rainbow.jpg. Make sure it's a valid image file

Try makePicture(pickAFile()). And make sure that your mediapath is on your disk (C:) not on the CD. Mark Guzdial


I continue to get the error message "error java.lang.ArrayIndexOutOfBoundsException" on the line "color=getColor(getPixel(Eagles,int(sourceX),int(sourceY)))" Any thoughts would be appreciated.
It sounds like you need to work out your math – you're sourceX or sourceY are beyond the edges of your Eagles picture. Mark Guzdial

are we able to view code from the movies that are posted? That is what I needed help on- I just wanted someone to post the code that they have so far because I am having some trouble getting started.
Why not start from one of the animation programs I gave you already? Mark Guzdial

I am also getting the message "error java.lang.ArrayIndexOutOfBoundsException" on the line "color=getColor(getPixel(bob,int(sourceX),int(sourceY)))" what kind of math do i need to do? why won't sourceX=1 and sourceY=1 work? it is a small picture so i know it's not too big...any suggestions?
Yes, sourceX and sourceY equal to 1 will work, but you're incrementing sourceX and sourceY. At some point in the execution, you're going beyond the ends of the picture. Simply stop incrementing it so far. Mark Guzdial


I'm getting the same error messages as above when I use the exact same code from the slides. I have set my mediapath and directory. I don't know what's wrong. This is what it says: Frame number: 0
I wasn't able to do what you wanted.The error java.lang.ArrayIndexOutOfBoundsException has occured
Please check line 13 of C:\Documents and Settings\Default\My Documents\move
That error has nothing to do with your mediapath and directory. It means that you are incrementing your array indices past the ends of the picture. Mark Guzdial


The code on the slides that tells us how to move Barb's head, moves her head diagonally up and down in the movie that it creates. The numbers used in the targetX and targetY ranges are seem to be pretty complicated. Can someone give me a hint of what kind of numbers I need to use in the ranges if I just want the picture to move in a straight line from left to right?
Look at the slides and the book – I explain the math step-by-step. Mark Guzdial


If you are getting string array index out of bounds errors in MovieMaker...

Try shortening the names of your folder. If you named it "AnimationPicsForCS1315" try "anims" or "pics." We're still tracking the bug, but it looks like that might fix it.

And you can always use MediaTools application to generate a .jmv – directions in the book and in MediaTools help. Mark Guzdial


IF YOU ARE DONE, PLEASE POST YOUR CODE- I NEED HELP

We are allowed to collaborate on the HW, please post the code if you are done with the HW. It would really help out
Suggestion: Get the code running where I move two rectangles. Mark Guzdial

yeah i dont know where to start either....do we start with the simple motion slide, tickertape slide, or moving barb's head??????? HELP!
ANY OF THESE THAT YOU WANT! It's like the collage assignment. Be creative! Mark Guzdial

I can't even view the movies that are already posted. I just downloaded QuickTime and MovieMaker, but when I click on the links to see the movies in motion, a blank screen comes up with a little box in the top left corner, but that's it. Any ideas?
Did you actually INSTALL QuickTime and MovieMaker? Just downloading them doesn't make them work. Mark Guzdial

I don't understand what I should be setting my targetX and targetY range to. At first I got out of bounds errors, now I am getting: Frame number: 1
< media.Picture instance at 21214616>
and then the code stops.What in the world is going on..?
You're printing your canvas. I don't know why you're code is stopping though. Maybe it's running but slowly? Mark Guzdial

how do you turn pictures into frames?
Pictures ARE frames – just write them out. Mark Guzdial

i don't understand why we need 2 functions. my program worked fine with just one function...
Because I want you to demonstrate that you understand how to work with multiple functions. Mark Guzdial

I wrote the code, used moviemaker to create slides, saved it as .mov when I created the movie, but where is the movie? I don't know where to go to find it and play it. Can somebody tell me where to find my movie so I can watch it...thanks.
Should be in the same folder as the frames. Mark Guzdial

Your movie should be in the same directory as the individual frames.

We keep gettin an error, invalid path, for this line
writePictureTo(framepict,dir+"//frame0"+framenum+".jpg")

We set dir="./HW5Frames"
But still get an error
Your directory can't be a relative path like that (using "."). Spell it out completely. Mark Guzdial


i loaded my program, and i am pretty sure it should work but i am getting the error "there was a spacing error in the program" and it says it is in the line where i have my sourceX=sourceX+2, I put it in the same place where it is in the lecture slides (with moving barb's head) and i have tried moving it around, but i still get that error message. Any suggestions?
Look at the spacing on the line BEFORE that line. That's often where the error is. When I get this, I change spacing to tabs or 3-spaces-per-level to make it easier to find the error. Mark Guzdial

This is my first 3 lines of code .. I keep getting error message refering to line 3.

def hw5(directory):
  for frame in range(0,100):
    movehead(directory,frame)



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.
any ideas with what could be wrong?
Where do you define movehead? How many inputs does movehead take? Mark Guzdial

In regards to above, I did install QuickTime and I did unzip the MovieMaker. Any other ideas why it's not showing me the animations?
Try your QuickTime movie on another computer. Maybe your video card isn't compatible with QuickTime? Mark Guzdial

I'm having problems running Prof. Guzdial's code in which two rectangles are set in motion. The code is from the "movies.2" lecture slides. I set the media path, and this message shows up in the command area: New media folder: C:\Documents and Settings\Mee Ae Park\My Documents\JES\mediasources\Movie Folder\
I have the recipe loaded, and I run the program but I get this 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.
Please check line 15 of C:\Documents and Settings\Mee Ae Park\My Documents\JES\Py Programs\hw5.py"
Line 15 is this line "writePictureTo(canvas,directory+"//frame0"+framenum+".jpg")"
I don't know where the bug is in this problem. Please help me. =)
Is canvas a picture? What is "directory"? Mark Guzdial

How to fix the blank frames promblem? Seems like barbara's head & a rectangle motions are really not in motion. But when I ran the code for these two pictures separately, it runs. I wonder why? Pls. someone wonder too & EXPLAIN?
I'm sorry, but I'm not understanding the question. I suggest asking in recitation or come see me (I have office hours 1-2 pm this afternoon.) Mark Guzdial

I am having the same problem as some of the postings above. My program is complete and I ahve created a directory in my JES folder for the frames. When I run the program using that directory, it runs through all the frames but stops when it gets to writePictureTo and gives 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." The problem is highlighted on the line that says "writePictureTo(canvas,directory+"//frame"+framenum+".jpg")". Any ideas on what to fix?


Are you sure that canvas is a picture? What directory are you handing in? Are you sure it's a valid path to the folder you created? Mark Guzdial


backgroundfile = makePicture(getMediaPath("background.jpg"))
show(backgroundfile)

For some reason, these lines don't work. I've set the mediapath, and have the picture in the folder, and the error it gives is: error occurred attempting to pass an argument to a function. I have no idea what's happening. please help-
print backgroundfile. What is it? Mark Guzdial

Prof. Guzdial pointed out that when running the function you have to make sure your directory is set up correctly. For instance, if you're using the movingRectangle2 function, in the command area, you'd need to call :
movingRectangle2(r"C:\Documents and Settings\Mee Ae Park\My Documents\JES\mediasources\Movie Folder")
I was doing something stupid because I had forgotten about how setMediaPath doesn't return anything.

 
well I just ran my code.. and in the command area I get frame 1, frame 2, frame 3... up to frame 99.. I am leaving a a portion of my code below..

def hw5(directory):
  for frame in range(0,100):
    movehead(directory,frame)
    movingrectangle(directory,frame)
    writeFrame(frame,directory,canvas) 



after it goes through frame 99, I get his error :A local or global name could not be found. You need to define the function or variable before you try to use it in any way. It is refering to the writeFrame line.. What i did was remove the writeFrame lines from my movehead and movingrectangle functions and extrapalated it out.. and added a return canvas at the end.. could u let me know how to solve this problem.. Thanks
I don't see where you're creating the canvas. Make sure that all the variables and functions you use are defined somewhere. Mark Guzdial

I am having the same problem as some of the postings above. My program is complete and I ahve created a directory in my JES folder for the frames. When I run the program using that directory, it runs through all the frames but stops when it gets to writePictureTo and gives 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." The problem is highlighted on the line that says "writePictureTo(canvas,directory+"//frame"+framenum+".jpg")". Any ideas on what to fix?
What is the canvas? try printing it. What is the directory? Is it a valid folder? Mark Guzdial
Is framenum an integer or a string? What is the difference between adding strings and integers? Adam Wilson


my canvas is 640x480.. I set it to that in the command area. My directory is a folder in Jes, which I also set. I am pretty sure it is a valid path to the folder I created..so why am I having the same problem as above?
No, PRINT the canvas. make sure that the variable "canvas" is a Picture object. remember that the directory can't END with "/" or "\". It must end with just the name of the folder. Mark Guzdial


I left the code up earlier.. the canvas is defined in the movhead and movingrectangle functions...and should it be spelling out each frame as the code runs?

If the canvas is defined in movhead and movingrectangle functions, then it's local to THAT context. It doesn't exist AT ALL in the hw5() function context. I'm not sure that I understand what you mean "spelling out each frame as the code runs." Each frame has to be written out separately. Mark Guzdial




can someone please post some code on how to have one main function and a separate sub funtion, i just need to know how to start each, it seems to be easier to make it all one.

Are you using writeFrame from the movie code? That's a separate function. POOF! You're done! Mark Guzdial


wait what?


To fit the requirements of the hw.. I took out the writeFrame function from movehead and moverectangle and defined it in a seperate function. In the powerpoint writeFrame takes the following input (num,directory,framepict), In recitation I was told to add the following line writeFrame(frame,directory,canvas) and place it after the makehead and movingrectangle functions in hw5.. that would take two seperate inputs.. So I changed both inputs to (frame,directory,canvas). I was also told to add a return canvas line at the end of the movehead function and movingrectangle function.. So when i run the program.. as it is running it prints out frame1 frame2 frame3.. till frame99.. Now the error i get is in the writeFrame function.. this is how it is in my code..

def writeFrame(frame,directory,canvas):
  # Have to deal with single digit vs. double digit frame numbers differently
  framenum=str(num)
  if num < 10:  
    writePictureTo(framepict,directory+"//frame0"+framenum+".jpg")
  if num >= 10:
    writePictureTo(framepict,directory+"//frame"+framenum+".jpg")


it now gives me the following error.. A local or global name could not be found. You need to define the function or variable before you try to use it in any way. refering to the framenum= line


The variables in the body of the function for writeFrame don't match the variables you're using for input. You're saying framenum=str(num), but you're handing in frame. maybe that should say something like framenum=str(frame)? Similarly, your code says framepict, but your input variable is canvas. num and framepict don't exist, so you are going to get errors on them. Mark Guzdial


i used the writeFrame function from the lecture slides but im not sure where to put it in my code. i can now only get one of my things to write out to frames.

def moveFlower(directory):
flower=makePicture(getMediaPath("flower.jpg"))
for frame in range(1,100):
canvas=makePicture(getMediaPath("640X480.jpg"))
sourceX=45
for targetY in range(frame*3,frame*3+((200-45)/2)):
sourceY=25
for targetY in range(frame*3,frame*3+((200-25)/2)):
—>color=getColor(getPixels(flower,int(sourceX),int(sourceY)))
setColor(getPixel(canvas,targetX,targetY),color)
sourceY=sourceY+2
sourceX=sourceX+2

i am getting an error on the line with the astrix it says that there is a syntax error not legal jython, but i cant see it maybe fresh eyes can tell me what its missing
You have getPixels. You meant getPixel. Mark Guzdial

ok i do not know how what i just put on did that
Because you can't use asterisks to define things in the CoWeb. READ THE FAQ ON HOW TO POST CODE. Mark Guzdial
it was just supposed to put up the code i am having problem with the line that says error

Professor Guzdial, thanks for all your help.. I fixed the problem with the writeFrame function.. and get no error messages now. I do though, when i run the program.. have this problem.. As the code is running it writes out frame number:1 next line frame number:2.. it keeps going until 99 and then starts over again. I have a return canvas line at the end of the movehead and movingrectangle function, i tried adding one to the last line of the hw5 function, and remove it from the movehead and movingrectangle function and it returns only one frame. I am kinda confused on what to do.. I am only inputing what i learned in recitation. Thanks again
I'd have to see your code to figure out what you're doing. The versions I've seen so far don't really need return(canvas). The most common mistake I've seen is that the canvas must be created in hw5(), not in the movingrectangle nor movehead functions. You can then pass the canvas in as input to movingrectangle and movehead (remove the lines in movingrectangle and movehead where you create the canvas), and write it at the end of hw5. Mark Guzdial


I have made a picture, it exists, it's a pdf picture, and I can print it, and it gives me it's hight and width, but when I try to show it, I get this error:
I think you meant a "JPG" picture, not PDF? Mark Guzdial
You are trying to access a part of the object that doesn't exist.
What is going on here?
Can you write it back out to disk using writePictureTo? I've dealt with one student's problem like this where JES somehow got fried. Here's how to test it: Do "c=makeEmptyPicture(480,640)" in the command area, then "writePictureTo(c,"mysample.jpg")" If you get an error, then you need to download a new JES from the Course Software (JES) page. That cleared up the problem Mark Guzdial

how do you move two pictures across the screen, meaning one entering from one side & the other entering from the other side.
Just change the math. To come from the left towards the right, means that you are INCREASING the X coordinate. To come from the right towards the left, use a high X value and DECREASE it across the frames. Mark Guzdial

def moveahead(directory):
  barbf=getMediaPath("barbara.jpg")
  barb = makePicture(barbf)
  for frame in range(1,100): #99 frames
    printNow("Frame number: "+str(frame))
    canvas = makePicture(getMediaPath("640x480.jpg"))
    # Now, do the actual copying
    sourceX = 45
    for targetX in range(frame*3,frame*3+((200-45)/2)):
      sourceY = 25
      for targetY in range(frame*3,frame*3+((200-25)/2)):
        color = getColor(getPixel(barb,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY), color)
        sourceY = sourceY + 2
      sourceX = sourceX + 2
    addRectFilled(canvas,100+ int(10 * sin(frame)),4*frame+int(10* cos(frame)),50,50,blue)
    # Now, write out the frame
    writeFrame(frame,directory,canvas)


def writeFrame(num,directory,framepict):
    # Have to deal with single digit vs. double digit frame numbers differently
    framenum=str(num)
    if num < 10:
      writePictureTo(framepict,directory+"//frame0"+framenum+".jpg")
    if num >= 10:
      writePictureTo(framepict,directory+"//frame"+framenum+".jpg")



 


how's that??? it works...does it fit the requirement????

Looks like it. If you want, you can mail me the movie to check it. Mark Guzdial


can the line where you say what the background is be outside the loop where you make the frames? or will doing that make the new frame write over the last one made, making a picture trail around the page?
If you make the background outside your frames loop, yes, the frames pile on top of one another and you get a trail. Sometimes that is what you want, and that's fine! Mark Guzdial

ok maybe I'm stupid, but I don't know how to work moviemaker.....I've got the frames in a folder, but what do I do from there???

Once MovieMaker is installed, run the .exe file. It'll ask you to pick the first and last frame, and then it will process all the frames from the first to the last.
Like the kind answerer said. Mark Guzdial

My question is what is MovieMaker??

WOW...
Agreed! See the link at the top of the page. Mark Guzdial

why in the code to move two triangles in the slide, does an error happen on the :
writePictureTo(framepict,directory+"//frame0"+framenum+".jpg")?
That was rectangles, not triangles, right? The obvious first question is: WHAT'S YOUR ERROR? Second, print framepict and directory to make sure that they're something reasonable. Mark Guzdial

i'm getting the array out of bounds error in MovieMaker and the folder my frames or in is named "hw5" so the long name thing is not the problem
It's not the folder name itself. The length problem is for the WHOLE path. So if you have /hw5 inside mediasources inside JES inside cs1315 inside My Documents inside...The path becomes really long. Mark Guzdial

what is the start frame and end fram that we need to put to make into a movie???
For start and end frames, click browse and go to the folder to where all the frames are. Select frame 01 for begin frame and whatever the highest number (last) is for end frame. Lauren Biddle

i looked at the other questoins on how to make my frames into a movie(which are working) but its not helping. i cannot get movie maker to make my movie and i tried using media tools and thats not working either. Code runs, but i need to test it.
You can also use MediaTools application to see your movie. Mark Guzdial

Your start frame will be whatever the first frame is. If you wrote it out as frame01, then that's it. End frame is the last frame. This gives MovieMaker the start and end points to assemble the movie. Jeff Baker

I can't get the movement of my picture to act the way I want it to. I have 118x30 pic added to a 500x200 canvas, and I am trying to make the picture move from right to left across the middle of the canvas. I have spent the last hour playing with the movie it produces, and I can't seem to make it start halfway down the canvas like I need it too. Any suggestions? Here is the problematic part of my code...
 
    sourceX=1
    for targetX in range((frame*9),(frame*9)+(75)):
      sourceY=1
      for targetY in range(1,30):
        color = getColor(getPixel(car,int(sourceX),int(sourceY)))
        setColor(getPixel(canvas,targetX,targetY), color)
        sourceY = sourceY +1
      sourceX = sourceX + 1
    writeFrame(frame,directory,canvas)

If your targetY is going from 1 to 30, you're going to be at the top of the image. Change that range to get the image to show up lower. Mark Guzdial THANKS - GOT IT WORKING!

where can we find the frames, it runs on jes but i need to find the frames to set it to the moviemaker.
In the directory you passed in as input to your hw5 function. Mark Guzdial

How do you pass the canvas in as input to movingrectangle and movehead and then write it in at the end of hw5()??
How do you pass a canvas as input to a function? Is that what you're asking?
def acceptPicture(canvas):
   ....blah blah blah

COMMAND AREA:
c = makePicture(pickAFile())
acceptPicture(c)

Hope that helps. Mark Guzdial

I AM SO FRUSTRATED! I am having problems creating the directory. I am typing in the command area: directory=r"C:\JES\mediasources\"
It returns: Your code contains at least one syntax error, meaning it is not legal jython.
I have set my MediaPath...what am I doing wrong?!
If you have a syntax error, it has NOTHING to do with the directory or the MediaPath. It means that some of your code is misspelled or has screwed up parentheses or spaces. It can't be read as Python. (It may mean that you should stop before 2 am and get some sleep :-) Mark Guzdial


Nevermind..figured it out..I rock!

I've tried this code:
background.addOvalFilled(red,ballX,ballY,20,20)
but it's saying 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.
please help, ballx & bally are numbers stated elsewhere, background is a picture, but this function doesn't seem to think so-
Try it at the Command line with an empty picture to make sure that it works the way that you think. Mark Guzdial

My picture won't show up. Is it possibly becuase of the picture i'm using?
I guess – that's a pretty vague question. Could you please be more specific? Mark Guzdial

How can I make the moving parts of my picture move slower?...They are moving so so fast!
Don't increment your x and y so much. If you increment by 5, they'll skip 5 every frame. If you increment by 1, things will slow down. Mark Guzdial


ok, here's my code. I can't figure out why my picture won't show up. Please help. Thanks. Oh, and i can't figure out what to do with the accectPicture func. Thanks.
pre def hw5(directory): for frame in range(1,31): canvas=makePicture(getMediaPath("640x480") printNow("Frame number: "+str(frame)) movingRectangle(directory,frame,canvas) movingMouse(directory,frame,canvas) # Now, write out the frame writeFrame(frame,directory,canvas) def writeFrame(num,directory,canvas): # Have to deal with single digit vs. double digit frame numbers differently framenum=str(num) if num 10: writePictureTo(canvas,directory+"//frame0"+framenum+".jpg") if num = 10: writePictureTo(canvas,directory+"//frame"+framenum+".jpg") def movingRectangle(directory,frame,canvas): addRectFilled(canvas,100+int(10*sin(frame)),4*frame+int(10*cos(frame)),50,50,yellow) def movingMouse(directory,frame,canvas): mousef=getMediaPath("mouse.jpg") mouse=makePicture(mousef) sourceX=1 for targetX in range(frame*885*3+(getWidth(mouse))): sourceY=1 for targetY in range(100,300): color=getColor(getPixel(mouse,int(sourceX),int(sourceY))) setColor(getPixel(canvas,targetX,targetY),color) sourceY=sourceY + 1 sourceX=sourceX + 1 def acceptPicture(canvas): canvas=makePicture(getMediaPath("640x480"))
I think I'm going to make a rule that I won't respond to your question about code AT ALL UNLESS YOU FOLLOW THE CODE POSTING RULES IN FAQ! It's not my job to keep formatting your code...

You can't break out the creation of the canvas as you do in acceptPicture. If you do it there, canvas isn't defined in hw5, so you can't write it out. I'd toss the function entirely. What's happening with your code that you need help with? Mark Guzdial


when i run my program it does everything fine and returns all the frame numbers, but when i go into the folder where my frames should be it only puts up frame 30. what happened to frames 1-29?
I don't know, but my guess is that you're only writing out the frame after frame >= 30, and not before. Check your IF statements and where you're writing out your frame. Mark Guzdial



Link to this Page