CST 205 | Multimedia Design and Programming

Course Description

Introduces design, creation, and manipulation of interactive applications and electronic media for communication purpose. Focuses on creating media, understanding media concepts, and manipulating the created media using basic programming concepts of control flow, functions, expressions and data types in the Python language. Students acquire a basic understanding for digital media formats, how to design, create such media using basic programming skills.

MidtermOutline.pdf

FILMIFY Code

#adds a white overlay look

def addWhite():

picture = makePicture(pickAFile())

for p in getPixels(picture):

#use 255 for RGB to add the white

newRed = 255*.2 + getRed(p)*(1-.2)

newGreen = 255*.2 + getGreen(p)*(1-.2)

newBlue = 255*.2 + getBlue(p)*(1-.2)

setColor(p, makeColor(newRed, newGreen, newBlue))

return picture

def filmify():

#Calling the addWhite() function

pic = addWhite()

#Getting fonts so I can use Helvetica

import java.awt.Font as Font

myFont = makeStyle("Helvetica", Font.BOLD, 50)

#Adding spaces in between the name makes for a cleaner look

addTextWithStyle(pic, 80, 80, "F I L M I F Y", myFont, white)

repaint(pic)

return pic

halfRed

def halfRed():

pic = get_pic()

pixels = getPixels(pic)

for p in pixels:

r = getRed(p)

setRed(p, r*0.5)

repaint(pic)

noBlue

def noBlue():

pic = get_pic()

pixels = getPixels(pic)

for p in pixels:

setBlue(p,0)

repaint(pic)


roseColoredGlasses

def roseColoredGlasses():

pic = get_pic()

show(pic)

pixels = getPixels(pic)

for p in pixels:

green = getGreen(p)

blue = getBlue(p)

setGreen(p,green*.5)

setBlue(p,blue*.5)

repaint(pic)

lightenUp

def lightenUp():

pic = get_pic()

pixels = getPixels(pic)

for p in pixels:

oldColor = getColor(p)

newColor = makeLighter(oldColor)

setColor(p, newColor)

repaint(pic)

makeNegative

def makeNegative():

pic = get_pic()

pixels = getPixels(pic)

for p in pixels:

setRed(p, 255 - getRed(p))

setBlue(p, 255 - getBlue(p))

setGreen(p, 255 - getGreen(p))

repaint(pic)

BnW

def BnW():

pic = get_pic()

pixels = getPixels(pic)

for p in pixels:

r = getRed(p)

g = getGreen(p)

b = getBlue(p)

l = (r+g+b)/3

setRed(p, l)

setGreen(p, l)

setBlue(p, l)

repaint(pic)

verticalMirror

def verticalMirror():

file = pickAFile()

pic = makePicture(file)

width = getWidth(pic)

height = getHeight(pic)

for x in range(0, width/2):

for y in range(0, height):

color = getColor(getPixel(pic, x, y))

setColor(getPixel(pic, x, y), color)

setColor(getPixel(pic,width-x-1, y),color)

repaint(pic)

horizontalMirror

def horizontalMirror():

file = pickAFile()

pic = makePicture(file)

width = getWidth(pic)

height = getHeight(pic)

for x in range(0, width):

for y in range(0, height/2):

color = getColor(getPixel(pic, x, y))

setColor(getPixel(pic, x, y), color)

setColor(getPixel(pic,x, height-y-1),color)

repaint(pic)

horizontalMirrorBottom

def horizontalMirrorBottom():

file = pickAFile()

pic = makePicture(file)

width = getWidth(pic)

bottomHeight = getHeight(pic)/2

height = getHeight(pic)

for x in range(0, width):

for y in range(0, bottomHeight):

topPixel = getPixel(pic, x, y)

bottomPixel = getPixel(pic, x, height - y - 1)

color = getColor(bottomPixel)

setColor(topPixel, color)

repaint(pic)

combineMirror()

def combineMirror():

file = pickAFile()

pic = makePicture(file)

width = getWidth(pic)

height = getHeight(pic)

for x in range(0, width/2):

for y in range(0, height):

color = getColor(getPixel(pic, x, y))

setColor(getPixel(pic, x, y), color)

setColor(getPixel(pic,width-x-1, y),color)

setColor(getPixel(pic,x, height-y-1),color)

repaint(pic)

rotatePic

def rotatePic():

file = pickAFile()

pic = makePicture(file)

width = getWidth(pic)

height = getHeight(pic)

newPic = makeEmptyPicture (height,width)

for y in range(0, height):

for x in range(0, width):

color = getColor(getPixel(pic, x, y))

targetPixel = getPixel(newPic, y, x)

setColor(targetPixel, color)

return newPic

makeCollage

def makeCollage():

pic1 = (makePicture("C:\Users\Daisy\Pictures\pic1.jpg"))

pic2 = (makePicture("C:\Users\Daisy\Pictures\pic2.jpg"))

pic3 = (makePicture("C:\Users\Daisy\Pictures\pic3.jpg"))

pic4 = (makePicture("C:\Users\Daisy\Pictures\pic4.jpg"))

pic5 = (makePicture("C:\Users\Daisy\Pictures\pic5.jpg"))

pic6 = (makePicture("C:\Users\Daisy\Pictures\pic6.jpg"))

pic7 = (makePicture("C:\Users\Daisy\Pictures\pic7.jpg"))

pic8 = (makePicture("C:\Users\Daisy\Pictures\pic8.jpg"))

mypic = makeEmptyPicture(2550, 3300)

pyCopy(pic1, mypic, 5, 59)

pyCopy(pic2, mypic, 705, 59)

pyCopy(pic3, mypic, 1200, 59)

pyCopy(pic4, mypic, 5, 1400)

pyCopy(pic5, mypic, 705, 1400)

pyCopy(pic6, mypic, 1400, 1400)

pyCopy(pic7, mypic, 522, 2582)

pyCopy(pic8, mypic, 1222, 2582)

writePictureTo(mypic, "C:\Users\Daisy\Pictures\collage.jpg")

explore(mypic)

return mypic

artify

def colorAdjust(color):

if color < 64:

return(31)

if color < 128:

return(95)

if color < 192:

return(159)

return(223)



def Artify():

pic = getPic()

pixels = getPixels(pic)

for p in pixels:

r = getRed(p)

g = getGreen(p)

b = getBlue(p)

setRed(p, colorAdjust(r))

setGreen(p, colorAdjust(g))

setBlue(p, colorAdjust(b))

repaint(pic)

mySnowman

def mySnowman():

#Can use this if I want to pick a file instead

#file = pickAFile()

#pic = makePicture(file)

#Choosing a file from a path on computer

file = "C://Users//Daisy//Pictures//desert-1270345_960_720.jpg"

pic = makePicture(file)

#using built in funtions to make the snowman

#top of snowman

addOvalFilled(pic, 480, 122, 160, 150, white)

#middle

addOvalFilled(pic, 480, 270, 180, 150, white)

#bottom of snowman

addOvalFilled(pic, 480, 418, 200, 170, white)

#left eye

addOvalFilled(pic, 510, 155, 15, 15, black)

#right eye

addOvalFilled(pic, 580, 155, 15, 15, black)

#nose

addArcFilled(pic, 488, 172, 80, 60, 30, 10, red)

#mouth

addRectFilled(pic, 544, 225, 25, 5, black)

#hat

addRectFilled(pic, 515, 47, 100, 80, black)

addRectFilled(pic, 485, 127, 130, 20, black)

explore(pic)

stPatricksDayGreetingCard

#Problem 1

def chloePic():

# Set up the source and target pictures

picturef = "C:\Users\Daisy\Pictures\luckyMe.jpg"

picture = makePicture(picturef)

canvasf = "C:\Users\Daisy\Pictures\chloe.jpg"

canvas = makePicture(canvasf)

#start copying

targetX = 0

for sourceX in range(0,getWidth(picture)):

targetY = 0

for sourceY in range(0,getHeight(picture)):

color = getColor(getPixel(picture,sourceX,sourceY))

setColor(getPixel(canvas,targetX,targetY), color)

targetY = targetY + 1

targetX = targetX + 1

show(canvas)

return canvas

#Problem 1 continued using chloePic funtion and adding text

def greetingCard():

pic = chloePic()

import java.awt.Font as Font

myFont = makeStyle("Helvetica", Font.BOLD, 50)

addTextWithStyle(pic, 228, 80, "You're my lucky charm!!!", myFont, pink)

repaint(pic)

#saves the picture to this path

writePictureTo(pic, "C:\Users\Daisy\Pictures\greetingCard.jpg")

return pic