Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import images.APImage;
- import images.Pixel;
- import java.util.Scanner;
- public class TestBlank{
- public static void main(String[]args){
- //Set up a scanner so that the program can read a blank line from the user
- Scanner reader = new Scanner(System.in);
- //Create an image from the image package (note: there is something wrong with window
- //the image appears in making it smaller than we want it to be the first time. Set
- //the size to 150 by 150 but it won't be until it is drawn again later.
- APImage image = new APImage(150, 150);
- //Actually put up the blank black image
- image.draw();
- //find the middle of the image
- int y = image.getHeight()/2;
- //for that middle work across each pixel on the x axis and change it to red
- for(int x = 0; x <= image.getWidth(); x++)
- image.setPixel(x, y, new Pixel(255, 0, 0));
- //Used to make the program wait to draw the red line
- System.out.print("Press return to continue:");
- reader.nextLine();
- //additional two lines that show where a pariticular pixel is so that you can judge the space
- Pixel p = image.getPixel(99,99);
- p.setGreen(255);
- //draw the image again so that there is a red line going through the middle and one green pixel
- image.draw();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement