Computer Graphics.

Slides:



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

Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.
Objectives Define photo editing software
Image Maps and Graphics Internet Basics and Far Beyond! Mrs. Wilson.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
COMP 14: Files and Graphics for Applets June 19, 2000 Nick Vallidis.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
A Simple Applet.
1 Internet Graphics. 2 Representing Images  Raster Image: Images consist of “dots” of color, not lines  Pixel: Picture element-tiny rectangle  Resolution:
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
Lesson 13 – Color and Typography. 2 Objectives Discuss basic color theory. Understand the color wheel. Understand how color is presented on a computer.
Java Software Solutions Lewis and Loftus Chapter 7 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphics -- Introduction The.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Nov 061 Size Control How is a component’s size determined during layout and during resize operations? Three factors determine component sizes: The component’s.
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.
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.
1 A Simple Applet. 2 Applets and applications An application is an “ordinary” program Examples: Notepad, MS Word, Firefox, Halo, etc. An applet is a Java.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Graphics. Graphic is the important media used to show the appearance of integrative media applications. According to DBP dictionary, graphics mean drawing.
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.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
Data Representation The storage of Text Numbers Graphics.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Drawing pictures … It’s not art, it’s fun.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
PART TWO Electronic Color & RGB values 1. Electronic Color Computer Monitors: Use light in 3 colors to create images on the screen Monitors use RED, GREEN,
Getting Started with GUI Programming Chapter 10 CSCI 1302.
Adobe Photoshop CS4 – Illustrated Unit A: Getting Started with Photoshop CS4.
Graphics Drawing Things With Java. Today's Topics Course Updates Java Graphics –Java 1.1 versus Java 1.2 (Java 2) Drawing Lines Drawing Shapes.
Photoshop CS6 – Nelson Unit 3: Photoshop CS6. Objectives Define photo editing software Start Photoshop and view the workspace Use the Zoom tool and the.
UNITS OF MEASUREMENT 2.01 Understand Digital Raster Graphics.
Intro to Graphics from Chapter 2 of Java Software Solutions
AP CSP: Pixelation – B&W/Color Images
Sprites (Images) and Sounds
Getting Started with Adobe Photoshop CS6
Pixels, Colors and Shapes
Binary Notation and Intro to Computer Graphics
Agenda Warmup Prep for Core #1 Lesson G2 (RGB, Loops in Graphics)
2.01 Understand Digital Raster Graphics
Vector vs. Bitmap.
Object Oriented Programming
Building Java Programs
Reading Netpbm Images.
Building Java Programs
Building Java Programs
Example: Card Game Create a class called “Card”
Chapter I Digital Imaging Fundamentals
Microprocessor and Assembly Language
LET’S LEARN ABOUT GRAPHICS!
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Basic Graphics Drawing Shapes 1.
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Building Java Programs
Graphics -- Introduction
2.01 Understand Digital Raster Graphics
CSE 142 Lecture Notes Graphics with DrawingPanel Chapter 3
Images Presentation Name Course Name Unit # – Lesson #.# – Lesson Name
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Graphics Reading: Supplement 3G
Presentation transcript:

Computer Graphics

Before Now In older computers, graphical output of computers was fairly limited. The Altair 8800 was one of the first personal computers that individuals could buy for themselves. It’s only input was a series of switches and only output was a series of lights.

Before Now Continued Other older systems relied on printers for text output, monochromatic screens (single color), or very small and/or low resolution screens.

Before Now Continued Even as computer systems started coming out with color displays, they were still low resolution with little color depth.

Current State Most current monitors have a resolution close to 1600 x 900. That means that they come with 1,440,000 pixels packed into their grid. 4K Ultra HD Displays though stretch into the range of 3840 x 2160 which means they pack in 8,294,400 pixels into their grid. And of course we are now seeing three dimensional visual displays being developed.

Coordinate Value On our current 2D displays each pixels corresponds to a coordinate value. This would appear to us to be fairly intuitive but there is one wrinkle. That one wrinkle is that our origin or (0, 0) coordinate is placed in the upper left hand corner. So why do this? The main reason is that that it allows us to anchor everything in that upper left hand corner Go on your computer and resize applications to see how everything is resized in relation to that upper left hand corner

Color Pixel Each pixel on our modern LED monitors are actually composed of three separate LED lights. There is one red, one green, and one blue light. By changing the intensity of each light, we can generate multiple colors. Keeping the blue light at full intensity and keeping the red and green off will of course produce blue. But lets say we turn the red and blue light on to full intensity and keep the green off, we then produce magenta.

Color Range In our standard monitors, red, green, and blue in each pixel has an 8 bit value assigned to their range of possible values. That means that each has a range of 0 to 255. And since each has a possible 256 possible values, we can generate over 16 million possible colors.

Color Choice JAVA uses the Color class to help us manage color selection. http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html Using the Color class we can reference a couple of standard colors like Color.ORANGE But most of the time we want to specify a color. In that case we would need to use the Color constructor to create a color. The one we will use is the constructor that takes in numerical values for red, green, and blue. So to produce magenta we could put: new Color(255, 0, 255)

More choice There are three ways to find which numerical values you need to use to create specific colors. The first is to look at an RGB chart which can be easily found online. The second is to use a color finder like we have in Paint or in other places online The following web site has an example of both: http://www.rapidtables.com/web/color/RGB_Color.htm The third option is to web search for the specific colors that you are looking for. For example, a web search for American Flag color values would result in providing these values: Red: 191, 10, 48 Blue: 0, 40, 104 White: 255, 255, 255 Note that Red and Blue are not exactly as we might have guessed

Drawing to the Screen JAVA provides to us a JPanel class which has a Graphics class inside of it with methods to draw various polygons to the screen. The first one we will use is fillRect. Others we will explore in later lessons. fillRect takes in four values which are x, y, width, and height These are fairly self explanatory except that the x, y which dictate the position are a reference to the upper left hand corner. That is again so that it will serve as the anchor point.

Example As we explore Computer Graphics, we will also take a look at another microcosm of graphical design. We will take a look at Vexillology or the study of flag design. The first flag that we will draw to the screen is the flag of Indonesia Notice it is composed of two rectangles where one is red and the other is white.

Coding The following is the code we will use to draw the flag g.setColor(Color.RED); g.fillRect(0, 0, 100, 600); g.setColor(Color.WHITE); g.fillRect(0, 100, 100, 600); Take note that we set the color before drawing the corresponding rectangle. Also take note that the two rectangles have the same x value, width value, and height value but the second rectangle has a different y so it will be positioned further down.

Better Code The following will produce a slightly better result: g.setColor(new Color(205, 17, 38)); g.fillRect(0, 0, 100, 600); g.setColor(Color.WHITE); g.fillRect(0, 100, 100, 600); For this we create our own red color that is more muted than bright red so it produces a better approximation of the red seen in the Indonesian flag.

Graphics Class We will be using the Graphics Class object to draw to the screen. A complete listing of the methods available to you can be found at: https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html The more common methods you will use are the following: drawLine(int x1, int y1, int x2, int y2) fillRect(int x, int y, int width, int height) fillOval(int x, int y, int width, int height) fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Take Note that the x and y of fillRect and fillOval are not the center but the upper left hand corner coordinate. Examples in each are included in your lab.

Project Start on the Flag Lab