NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/**
* This program is designed to draw geometric shapes on a Graphics2D panel and use horizontal and vertical mirroring to assemble individual panels into a composite picture
*
* @author Sijia Liang
* @version 8/5/16
*
*/
import java.awt.*;
import turtlegraphics.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
public class GeometricShapes
{
private Picture newCanvas = null;
private Graphics g = null;
private Graphics2D g2 = null;
private Picture pic1 = null;
private Picture pic2 = null;
private Picture pic3 = null;
private Picture pic4 = null;
private Color color = null;
private Picture drawing = null;
private Picture newerCanvas = null;

GeometricShapes(Color color, Picture canv, Picture p1, Picture p2, Picture p3, Picture p4, int length, int height, Picture newCanv)
{
newCanvas = canv;
newCanvas.setAllPixelsToAColor(Color.WHITE);
g = newCanvas.getGraphics();
g2 = (Graphics2D)g;
pic1 = p1;
pic2 = p2;
pic3 = p3;
pic4 = p4;
color = color;
drawing = new Picture(length, height);
newerCanvas = newCanv;
}

public void drawLine(Color color, int x1, int y1, int x2, int y2)
{
g2.setColor(color);
g2.drawLine(x1, y1, x2, y2);
}
public void drawOval(Color color, int x1, int y1, int width, int height)
{
g2.setColor(color);
g2.drawOval(x1, y1, width, height);
}
public void fillOval(Color color, int x1, int y1, int width, int height)
{
g2.setColor(color);
g2.fillOval(x1, y1, width, height);
}
public void drawRect(Color color, int x1, int y1, int width, int height)
{
g2.setColor(color);
g2.drawRect(x1, y1, width, height);
}
public void fillRect(Color color, int x1, int y1, int width, int height)
{
g2.setColor(color);
g2.fillRect(x1, y1, width, height);
}
public Picture getDrawing()
{
return drawing;
}
public Picture Flip()
{
Pixel targetPixel = new Pixel(pic1, 0,0); //set the coordinate for the image origin
Color pixelColor = null; //declare a Color object and set its initial value to null (or nothing)

Picture rightFlip = new Picture(200, 200);
Pixel targetPixel1 = new Pixel(rightFlip, 0, 0);

for(int y=0; y < pic1.getHeight(); y++) //outside nested loop to traverse the image from top to bottom
{
for(int x = 0; x < pic1.getWidth(); x++) //inside nested loop to traverse the image from left to right
{
targetPixel = pic1.getPixel(x,y); //gets the x,y coordinate of the target pixel
pixelColor = targetPixel.getColor(); //gets the color of the target pixel
targetPixel1 = rightFlip.getPixel(199 - x,y);
targetPixel1.setColor(pixelColor);
}
}
rightFlip.write("C:\Users\School-pc\Desktop\CP1 Course Files\Module 9\Mod09 Documents\HorizontalRightFlip.jpg");

Picture downFlip = new Picture(200, 200);
Pixel targetPixel2 = new Pixel(downFlip, 0, 0);

for(int y=0; y < pic1.getHeight(); y++) //outside nested loop to traverse the image from top to bottom
{
for(int x = 0; x < pic1.getWidth(); x++) //inside nested loop to traverse the image from left to right
{
targetPixel = pic1.getPixel(x,y); //gets the x,y coordinate of the target pixel
pixelColor = targetPixel.getColor(); //gets the color of the target pixel
targetPixel2 = downFlip.getPixel(x,199 - y);
targetPixel2.setColor(pixelColor);
}
}
downFlip.write("C:\Users\School-pc\Desktop\CP1 Course Files\Module 9\Mod09 Documents\VerticalDownFlip.jpg");

Picture diagonalFlip = new Picture(200, 200);
Pixel targetPixel3 = new Pixel(diagonalFlip, 0, 0);

for(int y=0; y < pic1.getHeight(); y++) //outside nested loop to traverse the image from top to bottom
{
for(int x = 0; x < pic1.getWidth(); x++) //inside nested loop to traverse the image from left to right
{
targetPixel = pic1.getPixel(x,y); //gets the x,y coordinate of the target pixel
pixelColor = targetPixel.getColor(); //gets the color of the target pixel
targetPixel3 = diagonalFlip.getPixel(x,199 - y);
targetPixel3.setColor(pixelColor);
}
}
diagonalFlip.write("C:\Users\School-pc\Desktop\CP1 Course Files\Module 9\Mod09 Documents\DiagonalFlip.jpg");

return rightFlip;
}
public Picture drawPicture()
{
g = newCanvas.getGraphics();
g2 = (Graphics2D)g;

g2.drawImage(pic1.getImage(), 0, 0, null);
g2.drawImage(pic2.getImage(), 200, 0, null);
g2.drawImage(pic3.getImage(), 200, 200, null);
g2.drawImage(pic4.getImage(), 0, 200, null);
return newCanvas;
}
public Picture drawBiggerPicture()
{
g = newCanvas.getGraphics();
g2 = (Graphics2D)g;

g2.drawImage(pic1.getImage(), 0, 0, null);
g2.drawImage(pic2.getImage(), 400, 0, null);
g2.drawImage(pic3.getImage(), 400, 400, null);
g2.drawImage(pic4.getImage(), 0, 400, null);
return newCanvas;
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.