Although these attachments are specific to Sections A and B, you should look at both!
Here is a quick link to the mediasources that are used in the textbook and in some of the slides: http://coweb.cc.gatech.edu/cs1315/3569#MediaSources Section A (MWF 10-11)
Pictures
Slides on the encoding of pictures as grids of pixels and colors in RGB: PicturesAndColors.pdf
Python code template for pixel-by-pixel transformation of a picture: Missing File (/cs1315/uploads/classDemo.py)
Example use of the above template for darkening a picture: darkenPicture.py
Example use of the above template for a series of effects as discussed in class Mon Jan 22. transformations.py
Program to give Prince Charles (or the celebrity of your choice) a purple rinse: purpleRinse.py This file contains two versions of purpleRinse(pixel) function: purpleRinse1(), which works correctly on all versions of JES, but uses the hand-coded distance calculation approach that I demonstrated in class, Jan 24; and purpleRinse2(), which uses the built-in Pythagorean distance() function and therefore requires the latest version of JES. Experiment with the color numbers and the threshold to get the effect you want. Don't like purple rinses? Try giving your celebrity orange highlights instead. Bleach that sober maroon necktie pink. Think up your own manipulation.
copyDemo code A bunch of copy functions that don't have that confusing use of targetX and targetY. Includes:
Copying
Copying with x,y offset
Reflecting
Rotating through 90 and 180 degrees
Scaling down
Not quite scaling up. (Can you see why this doesn't quite work? You need targetX and targetY to do this properly.)
Chromakey (selective copying)
Blending(copying with weighted combination of source and destination)
Movies
Slides (PDF) about movies: Missing File (/cs1315/uploads/movies.pdf).
Slides on sound encoding: Missing File (/cs1315/uploads/SoundEncoding.pdf)
If you get bored with the sounds included with the mediasources distribution from the download site or the CD, here is a cool site for finding sounds: http://www.findsounds.com/. When searching for files to use with JES, make sure that you specify WAVE files (.wav) only, and specify 16-bits per second (8-bits per second will play VERY quietly in JES). Sampling rate does not matter, so select the lowest to find the most sounds.
Function to normalize volume of a sound. (Note that the maximum value of a sample differs according to whether the sound is an 8-bit [-128..+127] or 16-bit [-32k..+32k] sound. Here is a function that you can use to distinguish whether a sound is 8-bit or 16-bit. As well as being useful, you could learn more about sound encoding by studying it.
Changing sound frequencies. Halving the frequency lowers the pitch (transposes down one octave, in musical terms); doubling the frequency makes the pitch higher (transposes up one octave). Note that doubling the frequency also shortens the note to one half its original length.
A step-by-step explanation of how to write a function that does some sound manipulation (i.e. Midterm Review, Sound Coding Q5)
Modules and reuse of existing functions:
You can find detailed documentation on all the modules in standard Python at www.python.org, and specifically at the python.org module index. (Warning, this is a useful background resource, but much of the module documentation assumes more knowledge of computing than you may have.) Particularly useful and relevant to what we discuss in class are the date, random and os modules.
Generation time vs viewing time Demonstration of the difference between finding the time when a page is generated by a Python program and the time when the page is viewed by a user. The generation time is found using time.ctime() and splicing the result into the page's text. From that moment on, the text of the time never changes and therefore becomes increasingly out of date. The viewing time is not known when you write the program or generate the page. (Obviously, because the page can be viewed many times at undetermined moments in the future.) The time is found by a piece of Javascript that is inserted into the page and that is run by the browser when the page is viewed. It therefore produces a different string each time it is called and is always accurate. The text of the time does not appear in the HTML source, just on the page as viewed by the user.
Some slides about networking in general: Missing File (/cs1315/uploads/network.pdf) (We won't go through these one by one in class, but they are a useful reference and back up the textbook coverage.)
More complicated turtle graphics. The Poly function for drawing repeated geometrical figures. Try this with different values of angle. (Changing the length of side will help you position and scale the image, but won't change the shape.) A simulation of a predator turtle chasing its prey. Make this fun by adding animal noises. Make it fair by having the predator slow down over time as it gets tired.
Breeds of dogs as classes and subclasses in Python. This is (almost) the example shown in class. You should study this example carefully to check your understanding of classes, subclasses, methods, inheritance of methods from superclasses, and overriding of methods.Breeds of dogs with constructors shows the previous example, but with __init__() constructors that determine the default height of the dog (so that dachshunds are lower to the ground than other dogs.)
Chameleons: A special species (i.e. subclass) of turtle that can change color. This illustrates how to write subclasses with new methods. Kaleidoscopic fun!
Frogs: A special species (i.e. subclass) of turtle that can jump and croak. This illustrates how to write subclasses with new methods. Mirth and cacophany!
Noisy frogs: As if frogs didn't already croak too much, NoisyFrog is a subclass of Frog that croaks twice as much when jumping. This illustrates how to subclass an existing subclass (i.e. Frog) and overwrite the definition of an inherited method (i.e. jump). Oh, and the pond simulation has the noisy frogs jumping and running the same amount, so the pond is even noisier. (It's Spring, after all.) If you run this for too many steps, you have some explaining to do to bystanders.
Simulating naturally occurring growth patterns using recursive turtle functions: Branching of trees. If you think this is too symmetrical, and doesn't look biological enough, add a bit (not too much) random noise to the angle through which the branching function generates its new buds, and you will be amazed. Try changing the randomization so that it isn't symmetrical and see what happens to the resulting shape.
The mysterious downUp function with a detailed explanation of recursion.
Some more recursive turtle programs: nestedTriangles and nestedSquares. nestedSquares() is interesting to watch for a while and then gets boring, but all the lines are in perfct register. nestedTriangle() draws many of its lines slightly off because of the rounding errors in JES's trigonometry. Since some of the multiply drawn lines are drawn in slightly different places, we get an unintended 3-D effect.