Blog

Blog

Project 5 - Lucas

This lab enabled me to code functions that would create collages.

The first task asked me to take what i learned in the lab, and expand upon it by adding another parameter to the list. I then tested this function by using the given testbuildcollage.py function.

For my second task, I went into my filter.py file to create a placePixmapNoBkg function, which has about the same functionality as placePixmap. but does not copy the src pixels into my destination image if the src pixel is part of a background green. I had trouble with this, but this is what I got.
In my third task, I edited my buildCollage function so that it used the background removal parameter in the collage info list. Here, I can store if I want the noBkg to be used.

I made a collage in my forth task using my buildCollage function. This is the combination of five different images.

In my last task, I created a "cover photo" using three photos and three different images.

extensions:
I created a new filter that makes images dimmer by 50%.

Gary Koplik and Vlad helped me a lot throughout my struggles in this Project.

Joe's CS151 Project 5

TASK SUMMARY: In the fifth project of CS151, students were asked to build on their last project by altering and manipulating more aspects of ppm image files. By using new features and strategies of Python, the programmers were implored to write code to make collages, cover photos, and filters. As in the last project, the graphics, display, and sys packages were used heavily.

TASK SOLUTIONS: The first task of this project was to create a function called <buildCollage>, that would be capable of taking a list, and creating a collage from the information in this list. This was fairly complicated to accomplish. First, I had to create a destination for the collage that would be big enough to hold all of the images. By using a function (which reads the locations specified for the photo and the size of each Pixmap) created in the lab, I stored the destination Pixmap as <dst>:

Next, I defined each aspect of the list according to its index in the list. This was fairly simple and easy, as we had defined each index in lab by name, not number:

Important to this step was defining the source image as the Pixmap index from the list.

Following this, I imported several of my filters from the previous project with If and Elif statements. These tell python to execute specific filters on the Pixmap it is currently placing, and are done with the following basic pattern:

Finally, I used my new <placePixmap> function to place the altered and relocated images in the correct locations. The new version of this function allows the programmer to control the transparency, or alpha blend value, of each Pixmap. This was done with an equation given to us by the lab instructors, and involves creating new variables r2,g2, and b2 as well as rnew, bnew, and gnew in order to apply the alpha value to the pixels. The final product looks like this:

As is evident, the function uses two for loops to loop over every pixel, and then implements several graphics commands on the source image and the destination before finally applying the alpha variable.

           The next task required students to create an additional function called <placePixmapNoBkg>, which would allow the collage function to remove the green screen from behind our head shots. This appeared to be fairly simple at first, but was actually not.

The first step was to loop over every pixel in the source Pixmap with two for loops, before acquiring using an if and else statement to only place those pixels that aren’t very green. The code looks like this:

In this way, I took a slightly different approach than was suggested by the instructions-- my code only alters the source image. Due to complications with other parts of my code, I could not alter the source image and send it to the destination in one single function. Instead, I created this code to remove the background, which is placed into my <buildCollage> function before the filters. By using an If statement, the programmer can decide whether or not to remove the background before any filters are added or the Pixmap is placed (this is also the 3rd task of the project). Thus, the background is removed, then the filter is applied, and then the final image is placed. This might seem slightly convoluted, but it is the best solution that the TA and I could come up with.

Here is the final code:

After doing this, I had to be sure that the lists I was inputting into the function contained the Boolean value <True>, not the string “True”. Python does not interpret them the same way, and thus cannot properly run the code.

           The fourth task was to create a new file that would use the <buildCollage> function to make a collage. To do this, I first created a list of lists, with each nested list containing correctly ordered information to create the collage. Next, I used the buildCollage function on this list, which I imported from collage.py. Lastly, I wrote the following code to tell Python what to build the collage in, and how to save it to the computer:

And here is the picture of that final collage, which inputs the desired pictures from the command line with the sys package and the argv command.

           The final task was to create a program that would generate a facebook-esque cover photo-- a collage at least 3 times wider than it is tall. This made it fairly easy, because it is basically the same code as the <mycollage> function. I created a collage list, used the buildCollage function on this list, and then told python where to put the Pixmaps and where to save the product. The only challenging part was figuring coordinates so that the pictures wouldn’t overlap. Here is the final image:

EXTENSIONS: I undertook two extensions for this project. The first was to enable my <placePixmapNoBkg> to remove a blue screen as well as a green screen. This was very simple: I merely had to copy the first If statement that removes green screens, and adjust the color conditions to test for very green pixels. Here is the final product, with both the green and blue conditionals included:

           The second was to create new effects (filters) than I had on my last project. This was very fun, for I got some cool ideas from looking at my classmate’s solutions to these filters. I made one very simple one that doesn’t change the image at all, and three different versions of “pop art.” This changes pixels that are very green, blue, or red to separate colors, which makes impressionist painting-like images. Here they are:



As evident, I made use of the alpha value in the last one too.

WHO I WORKED WITH: On this project, I worked with the TA’s Mathias, Paige, Kellin, and Will, as well as Prashant. Additionally, I consulted the following website to find the RGB values for particularly tricky colors.

[http://www.rapidtables.com/web/color/RGB_Color.htm
]

WHAT I LEARNED: This project taught me more about list organization, and the immense power they provide when transferring my ideas into python code. Additionally, I gained a better knowledge of Boolean values, as a few mistakes of mine created the need to understand them more. 

Yusheng's project 9

In this week's project, we learned how to create child class out of the parent class. In addition, we learned how to utilise dictionary, which makes a cleaner reference to the rules of our Lsystem.

The first task is to create a tree class which is a child class of shape class. Then we need to write out a test function to draw the tree L-system out. Basically, L-system.txt file is first reader by lsystem.py file and then turtle interpreter will draw the graph according to l-system. 


   Required image 1

The second task is to create some shape child class that can draw other basic shapes. I create Diamond, Hexagon, Trapezoid classes.Then I write a test function to draw them out. The graph looks like this:

Required  image 2

The third task is to create an indoor scene by using the classes in shape.py. The graph I created looks like this :


        Required image 3

The forth task is to create a mosaic image by multiplying a pile image. In mosaic.py function, I first write a pile function to draw a single pile graph out, which is a square with a triangle inside. Then I use double loop functions to draw a mosaic image with Nx*Ny pile graph. For the different color, I use random.choice function to choose one unspecified color from a color string sequence.

The graph I created looks like this:


      Required image 4 

Extension:

1. The first extension requires us to draw a non-square mosaic. For this extension, I created a extensionmosaic.py file, in which the basic tile is hexagon. In order to make the mosaic graph, I use math.sqrt() function to represent the square root of 3

2.The second extension requires us to draw some interesting graph by adding new element to turtle interpreter vocabulary. I write "L" and "o" that python would draw leaves and berries(as you can see in the third task).

3. The third extension required us to modify turtle interpreter that tree branches would seem like drop down due to gravity. In my turtle_interpreter.py file, I make some changes to "F" character. If the heading angle is bigger than 40 degree, I will divide the heading by 10, so that the heading angle would be smaller(which seems like drop down by gravity) The example graph is below(you can compare to the first task required picture):

4.For this extension, we need to create an animation. I use time module and time.sleep to pause the graph and turtle.clear() to clear the python just drew.


 
5. This extension required to make more tiles functions and to mosaic functions. I make two new piles functions in morepilemosaic.py. The graph looks like this

:
6. The final extension requires us to make a shape class where strings are the result of exciting a function. Then I created a class that will generate the string follow the argument I pass to that class. I created a polygon class. In polygon, I add a new parameter "sides". The default value of sides is 3. Then I use loop function to created a L-system string by the number of sides. (you can see polygon class in shapes.py file)

Yusheng's Project 7

In this project, we are getting our first exposure to L-system and properly-formatted text files. One interesting aspect of L-systems was iterations, which allowed us to draw complicated fractals and realistic plants.

The first task is to create an abstract image with three l-systems. All l-systems graphs shown. Through creating a new function that allow my shape to be drawn in any (x,y) with any scale, color, and pen width. The result are shown as image 1.

 
                       required image 1 

The second task is to create a grid of nine trees, where the number of iteration increased left to right and the angle changed from top to bottom. In this task, I used  two different loops. I also put three parameters to the function, which define the location I draw the graph and the scale of graph. 

For the extension part, I created a season theme throughout the grid. For top to bottom, three lines of trees represent the spring, auto and winter. In spring, the brach of tree has leaves. In automn, the tree has fruit on each of its brach and In winter, all leaves and fruits fall off. 


                         required image 2

The third task is to use different l-systems graphs to create a simple scene. The "sun" on the right of the sky is created by myself and I found the "snow" and two kinds of "tree" l-system in ABOP website.


                         required image 3

Extension:

1.I imported l-systems to my project 2 image.

2. I add 5 parameters to the show function in abstract.py file, in which filename defines the name of the file I inputed, d defines the scale of the graph, a defines the angle, x and y defines the position of graph, color defines the color string. 

3. I created a season theme throughout the grid.

4. I added x, y and scale parameters to the function in task 2. you can see in the right corner, I draw the grid with smaller scale.

5. I created three different l-system graph in task 1 and the sun in task3

6. I add berries and leaves to  trees in task2 and task3.

Yusheng Hu's Project 6

In this project, We learn how to use Zelle graphics to make animation. In order to create this animation, we started with designing a few complex shapes. Then we create an animation function for some of these shapes that are based on the frame number.

Tasks:

The images following are complex shapes that I create:

           sun

      appartment

  NYPD police car

Thief truck

NYPD police helicopter

house

skycraper

The whole graph looks like this:

  

My animation tells a story that. The thief trunk(red and blue car in the front) had just robbed a bank and kidnapped two bank clerks. Four
NYPD cars(white and blue cars in the behind) and a NYPD helicopter (helicopter in the sky) are chasing after the thief truck. 

                  comparison image

For animation part, I make five cars and helicopter move with different speed, which is achieved by make the shapes move with different pixels in each frame.  For the sun in the sky, I change the radius of circle on each frame so that it seems like "shining" in the sky. For NYPD cars and helicopters, I change the color of alarm lamp so that it seems more real. For the skycraper, I also write an animation function that can change the color of neon lamp. 
For extension: 

1. I make serval complex shapes and use the "for" loop

2. I also create a scene list that includes a list of value of parameters for complex shapes. Then I use "if and elif" to assign those value list to new parameters. Then I draw each shape out on a new window.

3. I make a animation with a simple story

4.Uh, It looks like a very simple action movie trail anyway.

Yusheng's project 5

The idea of this project for us to getting more use to pixmaps. One of the major thing is that we use list to store image information to build our collage more efficiently. The list contains information like image name, x-y position, alpha blending value and else. These lists were read using our readImages function and put into a collage.

The first task is to add a new parameter to the collage list, which controls whether to remove "very-green" and "very-blue"background. I create a new "placePixmapNoBkg" function which can collect all green background pixels and copy them to destination image. (Extension) In addition to this, I add a new parameter "c" in placePixmap NoBkg function, which indicates which background is used. So, this function can not only handle green background or blue background.

Then I download some pictures about The song of Ice and Fire online. The original photo looks like this

 

In mycollage.py file, I create a image of Baratheon.ppm stark.ppm Targaryen.ppm and yushengoriginal.ppm. I also apply symmetry filter, mosaic filter, symmetry filter and black and white filter to these images. In order to apply black and white filter to my photo, I create a special filter "bwwg", which means black white without green. In this filter, I apply black and white only to "no-green" pixels. Then I use placePixmaoNoBkg function to remove background. The resulting photo looks like this.

                           required image 1

My next task is to create a cover photo on Facebook. I apply many new filters to these six photos.  

The first filter is to reverse all color in the photo.

The second filter is to make a mosaic photo (maybe hard to see but this photo is actually blurred)

The third filter is to mix all red, green and blue color value.

The forth is filter is black and white.

The fifth filter is a mirror filter, which replaces all pixels on the left with pixels on the right. I also exchange red and blue color value  in every left side pixels 

The sixth filter is a symmetry filter, which replaces all pixels on the top with pixels on the bottom. I also exchange the red and blue color value in every top side pixels .

                      The required image 2

Extensions:

1.I created a few more new filters that are shown above in my cover photo and my collage photo.

2. For my second extension, I added a new  parameter "c" on placePixmapNoBkg that takes the string value where "b" means background is blue and 'g' means green Background.

3. I also created a diagonal shape for new geometric shape for my collage.

4. I added the mirror option into my collage information list to allow more adjustments. If mirror value equals to True, then Python would apply mirror filter on  image. 

6. For the sixth extension, I figured out how to call the proper function without using if/elif statement. The solution is to use dictionary method. Just like dictionary in our real life,  dictionary method in python works as follow, every keyword correspond to a value. So, in order to run a proper function, I just need to call te keyword in dictionary. (I learned this method by the help of Albert Zhang, sophomore) 

8. For the uber-extension, I put collage information in data.txt, and use a python file called readtextfile.py. In this file, I first read every line of the txt file by readline() function. Then, I create a new list which includes every line as a term of new list. After this, it comes another problem that the new list changes every elements of original line inside to string. To solve this problem. I set a new loop function, which changes all string type of value to other types of value, such as integer, bool and float. In this way, I create a file that changes txt file to the command line that I need.

This project was a practice of writing basic code in python to formulate simple shapes and ways to manipulate them. We used text wrangler to write the code and python in terminal to execute the commands.

For our first task we were asked to create a simple shape. I created an "L" shape by commanding the turtle to draw forward, turn left 90 degrees, and draw forward again.

For our second task we were asked to create another simple shape. Using commands forward and right 90 degrees, I created a square shape.

The third task practiced our ability to create a function. We turned our first two shapes into functions by commanding def (function name)(): and then the commands tabbed below. This meant we had two functions, named shapeA and shapeB after our first simple shape and second simple shape respectively. The third task then asked us to combine these functions in a third shape, which would be a function that combined shapeA and shapeB with a small command in between.

I coded: def shapeC (): 
shapeA()
forward(50)
left(30)
forward(50)
shapeB()

This function created a third shape that included the two simple shapes connected by a bent line.

The final task was to create a function that included parameters for a shape to make the shape's appearance more flexible, and then create a function that utilized this flexibility by printing the shape in different sizes. I named the first function, which was a square with flexible parameters, shapeD. To create this, instead of specifying a set distance after the command forward, I typed the word distance, and between each flexible distance I coded a right turn of 90 degrees.
EXAMPLE:
instead of forward(100), I typed forward(distance); and for the function setup instead of coding def shapeD():, I coded def shapeD(distance):
this allowed me to create a shape which could change size depending on the variable distance of each side

I then coded function shapeE to create four shapeD's of different size by tabbing: shapeD(specified side length) four times underneath def shapeE():. I made the four shapeD's of side length 50, 100, 200, and 300.

In this project I learned how to open and save files through terminal, type code in text wrangler and utilize python as a way to draw basic shapes. I learned how to keep my code neat and organized, and how to revise it for errors. i also learned to develop lab write-ups on the CS151 wiki page.

I was aided during this project by:
Mrs. Taylor

cs151s15project11

The purpose of this project was to use the z axis to create 3d shapes. We had to edit the draw functions and a few of the other methods to add the z axis and parameters.

Image 1:
I created four new methods in the shapes class and used the pitch function and F, +, - to create these shapes.I used the jitter and dotted styles as well.

Image 2:

For this scene, I used different sized prisms to create the buildings, using the scale function at the end of the draw function. I then used a for loop to create the blocks of grass outside the building then placed the hexagonal prism as the sun.

Image 3:

Lastly, for this task I created the 3d shapes to be built one within another. In order to do this, I created a triple for loop including the z axis and modeled it after the double for loops that we have done.

Extension:
For this extension, I created another 3d scene. In order to do this, I had to create the 3d X shape, for the "x marks the spot" and added in other shapes I made and used for loops for the grass and the pond of water. I sed the dotted style to create a more "realistic" map look, and used the roll function within the for loop of the dotted method to create the dots at different angles!

I learned how to use the z axis and how to think about how this affects my drawing. I also learned how to use the pitch and roll functions when drawing 3d shapes.

I received help from Bruce.

Project 8

This was our second project using L-systems. In this project, we made them by creating classes and methods inside of those functions. In this project, we made trees more complex by having multiple rule L systems. 

The first task was creating five additional characters to help us draw a tree with colored leaves. For the first required image, I used four of the tree L-Systems. Using looping, I made it so the trees went up diagonally across the screen by looping through a list of trees. I also made each tree increase in iterations each time through the loop which means you can increase iterations by controlling how many times to loop. In addition, I made the the positioning scalable so you could place this picture wherever. (arrangement.py)



For the second task, we had to create two new L systems and place them throughout the picture with different iterations. I did something similar to the grid.py where I increased iterations each time through a loop. I looped through a list of four trees where iterations was a function of the tree index. The top two rows of trees are my L-systems. They're variations of trees from the algorithmic botany with an additional characters to change trunk color and berries attached. 

Extensions:

1) I added characters to my turtle interpreter to add berries/fruits, trunk color, and color of branches. 

2)  By passing the '&' string to systemGL.txt, I made the leaves squares. I also made triangles by passing the ';' string to systemDL.txt


3) All of these came together in modifying the trees. I added variations to each tree to make it more interesting by creating strings and adding them in the Lsystems to make them a little more interesting. This extension was kind of a culmination of the first two extensions. 

I learned a lot about Lsystems and how to call methods from classes. 

References:

TA Mike

Olivia Stein

The purpose of this project was to become more familiar with L-systems, and change aspects such as color and width without affecting other elements of the object the turtle is drawing. In order to accomplish this task we first had to modify draw string so it supported five more characters. The second task was to write a function with an arrangement of trees or flowers that make use of the color store and restore. For this task I used multi-rule systems EL and DL. I modified the code in system DL by adding a T which changed the color of the tree to brown. I also modified the code in system EL by adding an O to make oranges. In order to make sure these changes were present in my drawing I edited my turtle interpreter. To make the orange I set the fill color to orange, drew a circle, ended the fill, and lastly set the color back to green for the rest of the tree. Here is an image of what this code draws. 

Required Image 1 

The third task was to make two new L-systems either by editing the code from one already made or creating a new L-system. I decided to create my own L-systems which can be seen in the mylsystem files. To do this I wrote a base, a rule, and then called these systems in my growth.py file. Here is an image of the L-systems I created.

Required Image 2 

Extensions 

I did two extensions for this project. My first extension was to create one more L-system. The code for this system is in the file extensionlsystem1.txt. This system draws a circular shape in magenta and is pictured in the center of the image below. 

Extension 1 

The second extension can be seen in the orange tree on the right of my required image 1. For this extension I added the variable o to the second rule of the systemEL file and added an elif c == "0" statement to draw string in my turtle interpreter.  

To complete this project I learned how to edit my turtle interpreter so I could change one aspect of the image without changing the entire picture and how to write my own L-systems.

List of people I worked with 
TA's 
Erin Lavoie
Mike Remondi 
Roxana Gheorghe 
Bilal Ahmad 

The purpose of this project was to become familiar with L-systems and writing code for fractal shapes. In order to do this we created a scene that consisted of elements from turtle graphic and fractal shapes. The first task was to create an abstract image using L-systems. The image included three different L-systems; I used systems A1, A2, and AB. I added color by inserting a variable in the L-system and using elif statements that assigned the pen to a specific color based on the variable. Here is a picture of my solution to task 1. (In the image the circular shape is in red, but in my code the color actually is dark blue because I changed it for my scene.) 

Required Image 1

 
The second task was to create a 3x3 grid with nine trees. To create this grid I used the L-system  saved in the systemB.txt file. The iterations of the grid increased from 1-3 starting from the left and the angles went from 22, 46, and 60 from the top to bottom. In order to this I used a double four loop as can be seen in the following code.  for x in range(-300, 300, 200): for y in range(-300, 300, 200): goto(x+10*scale,y+5*scale) it.drawString( lstrings[i], 7*scale, angles[j] )   j +=1 j = 0 i+=1
for x in range(-300, 300, 200):

for y in range(-300, 300, 200):

goto(x+10*scale,y+5*scale)

it.drawString( lstrings[i], 7*scale, angles[j] )  

j +=1

j = 0

i+=1

I made the angles equal to the variable j and the lstrings equal to the variable i. Here is an image of my grid. 

Required Image 2

The third and final task was to create a scene using at least two L-systems, one of which we had not previously used. For this scene, I took an L-system from page 25 of ABOP and put this in a file named systemC.txt.  I also used the L-system saved in the file systemA2.txt. I put these L-systems in my outdoors2 scene from project 2 to add a lake and another tree to the scene. Here is a picture of my scene. 

Required Image 3

Extensions

I completed my first extension in the third task where I just called one of my scenes from project 2 and added a fractal shape (the lake) and a tree to the scene. This extension can be seen in required image 3. 

For my second extension I made my abstract image function take in parameters (x,y, scale) and called the function 4 different times at different x,y locations and with a different scale value. This extension can be seen in the image below.  

In order to complete this project I learned how to create L-system generated objects and how to change things such as color by manipulating code within an L-system.

List of people I worked with

Professor Taylor

TA Bilal Ahmad

Alex Sisto's CS 151 Project 7

Alex Sisto

CS 151 Project 7

Due Date: April 7th 2015

Purpose

The purpose of this project was to become familiar with L-system grammars and use them to make visual images. We created two files, lsystem.py and turtle_interpreter to read a text file with the lsystem base and rule. Once that information has been read the turtle_interpreter interprets specific letters as different commands from the turtle module. I used these files to create multiple different fractal patterns and images containing fractals.

Task 1:

In task 1 the goal was to create an abstract image using only fractals. I found one lsystem rule in 'The Algorithmic Beauty of Plants' to make the large pyramid shaped fractals. This fractal also conveniently had space within to contain other fractals, so I inserted two copies each of two more fractals. I varied pen width and color to make the image more aesthetically pleasing.

Task 2:

In task 2 we had to make a 3x3 grid containing 9 copies of the systemB lsystem rule from lab. The number of iterations increase from 1 to 3 as one moves right across the columns. The angle between the branches increases from 22 to 60 going down rows.

Task 3:

For task 3 we were supposed to create a nonabstract scene containing a tree lsystem and at least two fractals. I fulfilled one extension by importing fractals into my project 2 file. I replaced the sun with the Koch's snowflake fractal. I found the rule and base code at http://mathworld.wolfram.com/KochSnowflake.html. For the trees I added leaves and berries to them fulfilling another extension. I built on the systemB lsystem and merely added two new letters at the end of each bracket. This means a berry and leaf are drawn at the end of each branch. I also had to edit the turtle_interpreter file to create new rules for the new letters I added into the lystem text file. The trees also have a random offset, like the original trees I had in my project 2.

Extensions

For my abstract image I added ( x, y, scale) functionality, as can be seen in the image below.

For another extension I chose to vary the color of each fractal by the column that it is located in. Column 1 is summer and green. Column 2 is fall and orange. Column 3 is brown and winter. I also enabled x, y, and scale inputs allowing me to place different sized file grids and different locations.

What I Learned

I learned how to use lsystems to create very complex patterns and images simply. Without the use of lsystems the images I made for the project would be incredibly difficult, if not impossible, to reproduce using just the knowledge I had when I did project 3. I am also becoming more and more comfortable with encapsulation.

Sources

The Algorithmic Beauty of Plants for the pyramid lsystem

http://mathworld.wolfram.com/KochSnowflake.html For the base and rule for Koch's snowflake.

The purpose of Project 4 was to change the pixel colors in order to form multiple pictures of the same image with different filters. These first task before adding the filters was to make a placePixmap function that called the image twice. In order to do this I called for python to loop over the height and the width of the picture and used getHeight and getWidth commands to figure these amounts simply. The next task was to create three more functions like swapRedBlue. To accomplish this task I divided and/or replaced some of the rgb values. The three functions I created were veryPurple, veryGreen, and veryRed as can be seen below. 

The next task was to take the 4 copies of the image and place them in one pixmap. I did this by creating a new file, warhol.py, that imported the filter.py file and called it and the images (called as maps) at different locations. To call the images at different locations I used the getHeight and getWidth commands. This image can be seen below.

The final task was to take our blue-screen image and change the blue pixels to another color. In order to do this I used an if statement that changed the pixels that were more blue than the red and green pixels by a certain amount to another color. Below is an image of the final product. 

I completed three simple extensions where I placed the warhol pictures in shapes other than a square. In the first extension I manipulated the locations of the images in order to create a diagonal.

 

In the second extension I added four more maps and called the images at different locations in order to create two diagonals. This function also made a square in the middle. 

For the third extension I added four more maps and called the images at different locations to create a border.

To complete this project I learned how to rearrange images within a function and how to use the getHeight and getWidth commands. I also learned how to change the color of pixels with and without if statements, and how to convert images to ppm files. 

List of people I worked with

Professor Taylor
TA's
Vlad Murad
Mike Remondi
Olivia Lang

cs151s15project4

Summary:

For our fourth project, our task was to use pixmap to manipulate the pixels to create different color schemes that we wanted. We then positioned them to be in the place that we wanted the pictures to be.

Our first task was to create a placePixmap function. With this function, we made sure that the all the pixels in the length and height would be manipulated and told the program where we wanted the pictures. The code for this looked like this: 

Next, I created different functions that would change the color of my image of miller. I changed around the r,g,b order as well as the numbers associated with them. In the r,g,b scale, we can use the numbers 0 through 255, with the color getting darker and closer to black the closer we got to 0. An example of the code that I wrote for these different color filters was:

After I created these three new filters, I now had my original picture of miller as well as three new filters to use. With these 4 different color filters, I made a warhol file that I would create a function in to make a warhol collage of four miller images with different effects. I made four copies of the pixmap using the clone function and named them map1,map2,map3, and map4. After doing this, I assigned a designated filter to each of the maps. For example, to assign my swapRedBlue effect to map1, I would write the code: filter.swapRedBlue(map1). After doing this, I created a new pixmap that was 2 by 2 by writing the code: 

Now I was able to place each picture of miller into the new 2 by 2 pixmap by using code:

This told the program to place map1 at the origin 0,0. I placed them in different places so they would come out in a square. This is what resulted:

Next, I created a conditional statement to change the green pixels from the screen, since we took a picture infront of the green screen, and change them to a different color if they were categorized as "very green". The code for this looked like such:

I used the conditional statement saying that if the green color was greater than or equal to 1.5times the red, and the green was greater than blue, to change the (r,g,b) values to (10,20,60). This changed the green screen, which was "very green" to a navy blue as shown below:

For my first extension, I created a filter that did something cooler than just replacing the green screen with a single color when it was "very green". In order to do this, I used the random function to assign random pixel colors in different ranges for the r,g,b values. The new, interesting green screen replacement I got was this:

The second extension that I did was to create some more filters, and then use the filters that I had to create a second warhol collage that was more complex and not in just a square shape like the first one. I drew out a 5 by 5 block and figured out which boxes would have a miller image with a filter so that they would be alternating, similar to how a chess board is. The 5 by 5 could not show the full thing on the screen, but I got enough to have it show and look like how I wanted it to.

What I learned: In this project, I learned how to use pixmaps and change the pixels in an image to change the colors and create cool effects. I also learned how to position photos on the pixmap where I wanted them to go. Additionally, I learned more about how to call different things better and became more comfortable using the conditional statements.

extension 3:

For my third extension, I placed myself in a scene that took all of the green screen and replaced it with the picture of the forest I was using. The code that I used for this was:

The final image that I got with me in the forest was this:

I worked with: Professor Taylor and Luc Marrie

Danqing's CS151 project 9

In this week's project we are supposed to get familiar with inheritance and class. Also, we learn how to use dictionary to build better lsystems. 

For the first task, I made this picture. These trees are created based on systemI, with iteration number 3. Since there are several replacement for one rule these trees are variable. 

I add some simple classes to my shapes document. As you can see, except square and triangle, i build pentagon, hexagon and star.

I also add color fill argument to every class. So that when I want to fill color in these figures I only need to set the fill value True. 

Next one is the indoor scene. As you can see, I create this scene only with figures shown above. At first I used loop and square class to build the mosaic floor and wall. To make them look better I set random color but control the range of rgb value. So the wall is generally blue and the floor is brown. 

The last task is the mosaic files. I create a simple file with a square and a star. To keep the random color of square and star different I set the star's rgb value in different order with square. 
Extension:

I create a hexagon mosaic picture. It is important to find out the location relationship of nearby files. I did it in this way:

tile(x+i*scale*3,y+j*scale*1.732,scale)
            tile(x+(i-1)*scale*3+1.5*scale,y+j*scale*1.732-0.866*scale,scale)
tile(x+i*scale*3,y+j*scale*1.732,scale)

tile(x+(i-1)*scale*3+1.5*scale,y+j*scale*1.732-0.866*scale,scale)
Next part is a new lsystem. I made some change to one of my old lsystem and get a totally new graph. This lsystem is shown below:
base V
rule V FV+FV+FV+FV+FV
rule F FF FFF
iteration number is 3 and angle is 144.

Next one is the tilt trees. To make this I make some change to the drawstring function. 
            #if t.heading()<90:
                #t.right(angle/20)
I also build a Ngon class. Since I had written similar code before it's quite easy. This class can draw Ngon with given number of sides. I add fill color argument to it. This is a simple example of class that can build string itself. 
In this week, I learned how to use class and dictionary to improve my lsystem and create more interesting graphs. I am now more familiar with these methods. 

People I worked with:

Pengyu Ren