CS 101 - Introduction to Computing, Spring 2007

Lab 7

This lab assignment will have you write a function in jython that will either lighten or darken an image 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:

  1. Clicking on Start
  2. Then click on All Programs
  3. Then click on Class Applications
  4. Then click on Engineering
  5. Finally click on Jython Environment for Students

Use of makeDarker() and makeLigher()

JES has two built-in functions that will modify the brightness of a color. The built-in help of JES describes these two functions are follows:
makeDarker makeDarker(color):
color: the color you want to darken
returns: the new, darker color
Takes a color and returns a slightly darker version of the original color.
makeLighter makeLighter(color):
color: the color you want to lighten
returns: the new, lighter color
Takes a color and returns a slightly lighter version of the original color.

As it turns out makeDarker() decreases values for each color by 30%, while makeLighter() increases the values for each color by about 40%.

Lab Assignment 7

Due: Tuesday 3/6/2007 by 11:59 pm

Create a file using JES that will:

  1. Contain a comment indicating

  2. Contain a JES function called modifyBrightness() that will

    If the parameter is a positive number, use makeLighter() to brighten the image. If the parameter is a negative number, use makeDarker() to darken the image. You may also need to call makeLighter() or makeDarker() multiple times based on the actual value of the parameter.

    For example, let us assume that modifyBrightness() is called with a parameter of -90. The call in the command area of JES would be:
    >>> modifyBrightness (-90)
    
    This command is telling us to darken the image by 90%. Since makeDarker() darkens a color by 30%, we will call makeDarker() three times to achieve this effect, since 90/30 equals 3. (Note that this calculation and logic is slightly flawed, but we will ignore that for this lab assignment.)

    For example, let us assume that modifyBrightness() is called with a parameter of 80. The call in the command area of JES would be:
    >>> modifyBrightness (80)
    
    This command is telling us to lighten the image by 80%. Since makeLighter() lightens a color by about 40%, we will call makeLighter() twice to achieve this effect, since 80/40 equals 2. (Again note that this calculation and logic is slightly flawed, but we will ignore that for this lab assignment.)

    If we are darkening the image, divide the parameter value by 30 and call makeDarker () that number of times for each pixel. If we are lightening the image, divide the parameter value by 40 call makeLighter() that number of time for each pixel. You are to preform integer division, thus ignore any results after the decimal place. For example

    Therefore:

    This function may call other functions that are built-in to JES or that you have written.

Submittal of the Lab Assignment

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.