CompSci 4 5.1 Graphics. CompSci 4 5.2 The Plan  Hardware  Coordinate System  Built-in Shapes  User-defined Shapes  Sprites and Shapes  Making a.

Slides:



Advertisements
Similar presentations
The Three-Dimensional Coordinate System 11.1
Advertisements

Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics.
The Cartesian Coordinate System
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics F The architecture.
Swing Graphics ● Empty Swing containers have no visual appearance except for a background color ● Every JComponent must have a paintComponent method that.
Polar Coordinates Definition, Conversions, and Integration.
Do Now - #18 on p.558 Graph the set of points whose polar coordinates satisfy the given equations and inequalities.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
POLAR COORDINATES (Ch )
Copyright - Planchard 2012 History of Engineering Graphics Stephen H. Simmons TDR 200.
Interactive Input Methods & Graphical User Input
3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0.
1 Graphical User Components (II) Outline JTextArea Creating a Customized Subclass of JPanel JPanel Subclass that Handles Its Own Events Windows: Additional.
CGMB214: Introduction to Computer Graphics
1.00 Lecture 18 Geometric Transformations in the 2D API.
Chapter 15 Graphics and Java 2D™ Java How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction.
Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction 28.2Graphics Contexts and Graphics Objects 28.3Color Control 28.4Font Control 28.5Drawing.
 Pearson Education, Inc. All rights reserved. 1 Ch 12 Graphics and Java 2D In this chapter you will learn:  To understand graphics contexts.
(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci.
Advanced User Interfaces with Java SD’98 - Session 3206 Ted Faison Faison Computing Inc.
Geometric Modeling. Volumetric o Collection device obtains regular grid of measurement values Examples: CT, MRI, PET, Ultrasound o Values are interpreted/visualized.
2D Graphics Basics Chapter 2. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics –Basic 2D graphics, rendering pipeline, geometry,
Drawing and Filling Geometric Shapes. Java comes with more than just points and lines. Within the Graphics2D class, there are also methods for drawing.
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
Introduction to Java Chapter 8 - Introduction to Java Graphics1 Chapter 8 Introduction to Java Graphics.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
Georgia Institute of Technology Drawing in Java – part 3 Barb Ericson Georgia Institute of Technology September 2006.
Java Graphics Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zOffset between class.
Lesson 1-7: Perimeter,Circumference & Area Warmup A has coordinates (3, 8). B has coordinates (0, –4). C has coordinates (–5, –6). 1. Find the distance.
8.1 The Rectangular Coordinate System and Circles Part 2: Circles.
Graphics in Java Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have any questions.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Projects: not limited to spec Error checking File filters Create multiple file formats Polygons Filled shapes Etc.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
8.1 The Rectangular Coordinate System and Circles Part 2: Circles.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
Eleventh Graphics in Java.
12 Graphics and Java 2D™.
What is a Function Expression?
Java Graphics CS 2511.
Graphics.
Two-Dimensional Sketching
Coordinate Reference Frames
Engineering Geometry Engineering geometry is the basic geometric elements and forms used in engineering design. Engineering and technical graphics are.
JAVA 2 Design and programming of GUI
Basic Graphics Drawing Shapes 1.
Computer Graphics.
Sketch the region enclosed by {image} and {image}
17.1 Equation of a Circle How can you write the equation of a circle if you know its radius and the coordinates of its center?
Interactive Input Methods & Graphical User Input
Area & Riemann Sums Chapter 5.1
Digital Media Dr. Jim Rowan ITEC 2110.
1.
Interactive Input Methods & Graphical User Input
Chapter 49 Java 2D.
POLAR COORDINATES Dr. Shildneck.
Coordinate Systems Dr. Midori Kitagawa.
The coordinate system Susan Ibach | Technical Evangelist
Handout-14 Applets and Graphics
Presentation transcript:

CompSci Graphics

CompSci The Plan  Hardware  Coordinate System  Built-in Shapes  User-defined Shapes  Sprites and Shapes  Making a Sprite

CompSci Hardware  Monitor  Resolutions (640x480, 800x600, 1280x1024)  Bit depth (8, 15, 16, 24, 32)  Refresh rate (75-85 Hz)  Video Card  Assists monitor  Optimizes graphics

CompSci Coordinate Systems  Cartesian  Polar  Screen (Graphics)  Java 2D (Graphics2D)

CompSci Coordinate Systems  Cartesian  Rectangular  X increases to the right  Y increases as you go up  Origin typically at center  Real valued

CompSci Coordinate Systems  Polar  r increases as distance from the origin increases  theta increases in the counterclockwise direction  grid lines make concentric circles and sectors  Origin typically at center  r is real valued  theta is from 0 to 2*PI

CompSci Coordinate Systems  Conversion between Cartesian and Polar  [x, y] = [r*cos(theta), r*sin(theta)]  r = sqrt(x*x+y*y)  theta = acos(x/r) if y>0  theta = - acos(x/r) if y<=0  No need to memorize this, but you may see it in the code

CompSci Coordinate Systems  Screen (Graphics)  Rectangular  X increases to the right  Y increases as you go down  Origin at upper left  Non-negative integer valued

CompSci Coordinate Systems  Java 2D (Graphics2D)  Rectangular  X increases to the right  Y increases as you go down  Origin at upper left  Real valued (approximated)

CompSci Coordinate Systems  Java2D to Screen conversion  Simple – round the floating point to an integer (or just truncate)  Screen to Java2D conversion  None needed because integers are approximated reals

CompSci Coordinate Systems Why use Java2D coordinate system?  Smoother motion  Integer values often need to be rounded which can lead to more calculation error  Simpler to rotate and expand

CompSci Built-in Shapes In java.awt.geom package  Ellipse2D.Double  Rectangle2D.Double  RoundRectangle2D.Double  All constructed with (x, y, width, height)  What about circles and squares?

CompSci User-defined Shapes Also in java.awt.geom  GeneralPath  Lines  Curves o Quadratic o Cubic  Can be transformed via AffineTransform  Area  Constructive Area Geometry  Useful tool for finding intersections

CompSci Shapes All classes so far are all Shapes  Can draw them using a Graphics2D  Can get boundary information  Can be used to make a Sprite…

CompSci Sprites and Shapes Sprites have  Size  Shape  Orientation  Location  Color  Optionally a Tracker

CompSci Making a Sprite How to make a Sprite: 1. Extend Sprite 2. In the constructor a. Call super() b. Make any Shape c. Call setShape(yourShape)

CompSci Making a Sprite package tipgame.game.test.sprite; import java.awt.geom.*; public class SquareSprite extends Sprite { public SquareSprite() { super(); Rectangle2D.Double rectangle; rectangle=new Rectangle2D.Double(0, 0, 1, 1); setShape(rectangle); } How to make a Sprite: 1.Extend Sprite 2.In the constructor a.Call super() b.Make any Shape c.Call setShape(yourShape)

CompSci Making a Sprite See the video game engine web site for the source code examples that follow

CompSci Making a Sprite In the constructor of LightSprite: super(); Area area=new Area(); Rectangle2D.Double box=new Rectangle2D.Double(0, 0, 0.2, 0.6); area.add(new Area(box)); Ellipse2D.Double circle=new Ellipse2D.Double(0.02, 0.02, 0.16, 0.16); area.subtract(new Area(circle)); circle=new Ellipse2D.Double(0.02, 0.22, 0.16, 0.16); area.subtract(new Area(circle)); circle=new Ellipse2D.Double(0.02, 0.42, 0.16, 0.16); area.subtract(new Area(circle)); setShape(area);

CompSci Making a Sprite In the constructor of TriangleSprite: super(); GeneralPath path=new GeneralPath(); path.moveTo(0.0f, 0.0f); path.lineTo(1.0f, (float)Math.sqrt(3)); path.lineTo(-1.0f, (float)Math.sqrt(3)); path.closePath(); setShape(path);