1 / 6

Making a Smile Face

Making a Smile Face. Pepper. Code you have.

teresa
Download Presentation

Making a Smile Face

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Making a Smile Face Pepper

  2. Code you have •        DrawingPanel panel = new DrawingPanel (300, 200);       Graphics g = panel.getGraphics ( );       //first smiley face       g.setColor (Color.YELLOW);       g.fillOval (20, 10, 50, 50);       g.setColor (Color.BLACK);       g.fillOval (32, 25, 7, 7);       g.fillOval (50, 25, 7, 7);             g.drawOval (30, 37, 30, 15); // drawOval instead of fill to get a line       g.setColor (Color.YELLOW);// draw the blackout box       g.fillRect (30, 33, 30, 10);       //second smiley face       g.setColor (Color.YELLOW);       g.fillOval (230, 10, 50,50);       g.setColor (Color.BLACK);       g.fillOval (242, 25, 7, 7);       g.fillOval (260, 25, 7, 7);       g.drawOval (240, 37, 30, 15);       g.setColor (Color.YELLOW);       g.fillRect (240, 33, 30, 10);

  3. Graphics methods

  4. Finding relationships What is the relationship between the 20,10 Big Circle start and the 32,25 eyes? •        DrawingPanel panel = new DrawingPanel (300, 200);       Graphics g = panel.getGraphics ( );       //first smiley face       g.setColor (Color.YELLOW);       g.fillOval (20, 10, 50, 50);       g.setColor (Color.BLACK);       g.fillOval (32, 25, 7, 7);       g.fillOval (50, 25, 7, 7);             g.drawOval (30, 37, 30, 15); // drawOval instead of fill to get a line       g.setColor (Color.YELLOW);// draw the blackout box       g.fillRect (30, 33, 30, 10);       //second smiley face       g.setColor (Color.YELLOW);       g.fillOval (230, 10, 50,50);       g.setColor (Color.BLACK);       g.fillOval (242, 25, 7, 7);       g.fillOval (260, 25, 7, 7);       g.drawOval (240, 37, 30, 15);       g.setColor (Color.YELLOW);       g.fillRect (240, 33, 30, 10); 32 is 12 over and 15 down, so You can set x = 20 and y = 10 And make the big circle with g.fillOval(x,y,50,50) And make the eye with g.fillOval(x+12,y+15,7,7)

  5. Coded with relationships •        DrawingPanel panel = new DrawingPanel (300, 200);       Graphics g = panel.getGraphics ( );      int x = 20; int y = 10;  //first smiley face       g.setColor (Color.YELLOW);       g.fillOval (x, y, 50, 50);       g.setColor (Color.BLACK);       g.fillOval (x+12, y+15, 7, 7);       g.fillOval (x+30, y+15, 7, 7);             g.drawOval (x+10, y+17, 30, 15); // drawOval instead of fill to get a line       g.setColor (Color.YELLOW);// draw the blackout box       g.fillRect (x+10, y+23, 30, 10);      x = 230; y = 10;        //second smiley face       g.setColor (Color.YELLOW);       g.fillOval (x, y, 50, 50);       g.setColor (Color.BLACK);       g.fillOval (x+12, y+15, 7, 7);       g.fillOval (x+30, y+15, 7, 7);             g.drawOval (x+10, y+17, 30, 15); // drawOval instead of fill to get a line       g.setColor (Color.YELLOW);// draw the blackout box       g.fillRect (x+10, y+23, 30, 10);

  6. Coded with Methods •        DrawingPanel panel = new DrawingPanel (300, 200);       Graphics g = panel.getGraphics ( );   smile(10,20); //first smiley face smile (230,10); // second face • public static void smile(int x, int y){ g.setColor (Color.YELLOW);       g.fillOval (x, y, 50, 50);       g.setColor (Color.BLACK);       g.fillOval (x+12, y+15, 7, 7);       g.fillOval (x+30, y+15, 7, 7);             g.drawOval (x+10, y+17, 30, 15); // drawOval instead of fill to get a line       g.setColor (Color.YELLOW);// draw the blackout box       g.fillRect (x+10, y+23, 30, 10);      }

More Related