Making a Smile Face Pepper.

Slides:



Advertisements
Similar presentations
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Advertisements

Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Topic 9 more graphics Based on slides bu Marty Stepp and Stuart Reges from
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
1 Chapter 15 l Basic Figures l Colors l Fonts and Other Text Details Graphics Objects.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Week 3 parameters, return, math, graphics Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise.
Slides prepared by Rose Williams, Binghamton University Chapter 19 Swing II.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 16 : Swing VI Graphics King Fahd University of Petroleum & Minerals College of Computer.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
1 Drawing Shapes and Text With Applets. 2 Drawing in the paint method import java.awt.*;// access the Graphics object import javax.swing.*;// access to.
INTRODUCTION TO PYTHON PART 5 - GRAPHICS CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Java Programs u 1 project file –with an extension of.mcp –contains information that CodeWarrior needs to run the program u >= 1 source files –have an extension.
1 Graphical objects We will draw graphics in Java using 3 kinds of objects: DrawingPanel : A window on the screen. Not part of Java; provided by the authors.
Graphics. Graphics Features in Java Topics to be covered Topics to be covered Graphics Basics Graphics Basics Coordinate System Coordinate System Graphics,
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Copyright 2010 by Pearson Education Building Java Programs Graphics reading: Supplement 3G.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Chapter 15Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 15 l Basic Figures l Colors l Fonts and Other Text Details.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Applets Applet is java program that can be embedded into HTML pages. Java applets runs on the java enabled web browsers such as mozilla and internet explorer.
Unit 3 parameters and graphics Special thanks to Roy McElmurry, John Kurkowski, Scott Shawcroft, Ryan Tucker, Paul Beck for their work. Except where otherwise.
CPS Today’s topics Java Applications Graphics Upcoming Review for Midterm Exam Reading Great Ideas, Chapters 5.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Introductory Graphics Chapter Three. Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft.
Building Java Programs Graphics Reading: Supplement 3G.
CS305j Introduction to Computing Simple Graphics 1 Topic 11 Simple Graphics "What makes the situation worse is that the highest level CS course I've ever.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans.
1 CSE 331 Design Patterns 2: Prototype, Factory slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer
Please open JCreator and follow these steps: 1)Configure  Options 2)JDK Tools 3)Choose Run Applet from drop-down 4)Click Default, then Edit 5)Click the.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CPCS 391 Computer Graphics Lab One. Computer Graphics Using Java What is Computer Graphics: Computer graphics are graphics created using computers and,
CS202 Java Object Oriented Programming GUI Programming – Color and Drawing Methods Chengyu Sun California State University, Los Angeles.
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
Building Java Programs
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
Building Java Programs
Building Java Programs
A note on Programming Assignment
Example: Card Game Create a class called “Card”
Building Java Programs
Today’s topics Java Applications Upcoming Reading Graphics
parameters, return, math, graphics
Basic Graphics Drawing Shapes 1.
Topic 8 graphics "What makes the situation worse is that the highest level CS course I've ever taken is cs4, and quotes from the graphics group startup.
Building Java Programs
CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random
Building Java Programs
Parameters Readings: 3.1.
CSE 142 Lecture Notes Graphics with DrawingPanel Chapter 3
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Topic 9 More Graphics Based on slides bu Marty Stepp and Stuart Reges from
Building Java Programs
Building Java Programs
Building Java Programs
Graphics Reading: Supplement 3G
Building Java Programs
Presentation transcript:

Making a Smile Face Pepper

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);

Graphics methods Method name Description drawLine(x1, y1, x2, y2) line between points (x1, y1), (x2, y2) drawOval(x, y, width, height) draws outline of largest oval that fits in a box of size width * height with top-left corner at (x, y) drawRect(x, y, width, height) draws outline of rectangle of size width * height with top-left corner at (x, y) drawString(text, x, y) writes text with bottom-left corner at (x, y) fillOval(x, y, width, height) fills largest oval that fits in a box of size width * height with top-left corner at (x,y) fillRect(x, y, width, height) fills rectangle of size width * height with top-left corner at (x, y) setColor(Color) Sets Graphics to paint subsequent shapes in the given color

Finding relationships        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); What is the relationship between the 20,10 Big Circle start and the 32,25 eyes? 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)

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);

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);       }