Lab 8
This lab assignment will have you write a function in jython
that will created a new images that will vertically repeat a
picture
by an amount given as a
parameter.
Reminder
The program Jython Environment for Students (or JES) is the
development environment that we will use for this lab.
In the ACCC Labs that have JES, it can be found by:
- Clicking on Start
- Then click on All Programs
- Then click on Class Applications
- Then click on Engineering
- Finally click on Jython Environment for Students
Duplicating and Image
The following code was taken from lecture on 2/22/2007.
It shows how to take an image and create a new image with
the original image appearing twice side-by-side.
def duplicateHorz():
#Allow the user to pick up an image file
file = pickAFile()
#now convert the image in JES format
pic = makePicture(file)
orig_width = getWidth (pic)
orig_height = getHeight (pic)
new_pict = makeEmptyPicture (orig_width*2, orig_height)
for x in range (1, orig_width):
for y in range (1, orig_height):
opix = getPixel(pic, x,y)
npix1 = getPixel (new_pict, x, y)
npix2 = getPixel (new_pict, x+orig_width, y)
c = getColor (opix)
setColor(npix1, c)
setColor(npix2, c)
openPictureTool(new_pict)
|
For this week's lab, you are to write a funcction that will take an
integer value as its parameter. The function is to vertically
diplicate an image (which is selected by the user using pickAFile()).
The bew image will have the original image appear the same number of times
as the value of the parameter.
If the parameter has the value of 1, the function will just make a
copy of the original image.
If the parameter has the value of 2, the function will create an image
that has 2 copies of the original image, one on top of the other.
If the parameter has the value of 3, the function will create an image
that has 3 copies of the original image, the first on top of the second
and the second on top of the third.
The value of the parameter will
need to be checked to make sure it is 1 or greater.
Lab Assignment 8
Due: Tuesday 3/13/2007 by 11:59 pm
Create a file using JES that will:
- Contain a comment indicating
- your Name,
- Net-ID,
- Course Name,
- Assignment Name and
- a short description of
the assignment
- Contain a JES function that will:
- take a numeric value as a parameter given as an integer number.
This value will indicate the number of duplicate images the final
canvas will contain.
- verify that the number is 1 or greater.
- allow the user to pick an image using pickAFile().
- use makeEmptyPicture() to create a blank canvas that will hold
the proper number of duplicate images.
- make the proper number of copies in the canvas. These copies
are to be stacked vertically (one on top of the next).
- display to created image
- allow the user to save the created image in a file whose name
is specified by using pickAFile().
If the command area of JES would be:
>>> duplicateVertical (1)
|
The result would be:
If the command area of JES would be:
>>> duplicateVertical (2)
|
The result would be:
If the command area of JES would be:
>>> duplicateVertical (3)
|
The result would be:
This function may call other functions that are built-in to JES or
that you have written.
Submittal of the Lab Assignment
- You are submit your program electronically by placing it in the
digital drop box in blackboard.
- Programs that are correct and
submitted by noon on the Wednesday
the lab assignment is discussed will receive an extra 10% on the
score of the lab.
- When saving your program, use a meaningful name like lab8.py.
- When submitting your lab assignment, place all of the needed files it in a
zippped folder (even if you are only submitting one file) with the name
of yournetid_labX and submit that zipped folder to the digital
drop box. For instance, if your net id is
abc32 then the folder name should be abc32_lab8.
Comments on the ACCC Labs
On the computers in the ACCC Labs there should an H: drive.
This drive is actually a networked connection to your own file space
maintained by the ACCC. No matter what machine you use or what lab
you are in, the H: drive will access the same file space. This means
that you can save a file on the H: drive on a computer in one lab and
access that same file on a computer in another lab. This can be very
helpful. It is suggested that you store your python program files
on your H: drive.