Class Meeting 05 (Lecture 04) Objectives for this class meeting. Conduct vote on basic style of game for class project

Similar documents
Software System Components 1 Graphics

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

CSE1720. Objectives for this class meeting 2/10/2014. Cover 2D Graphics topic: displaying images. Timer class, a basic ActionListener

public void paintcomponent(graphics g) { Graphics2D g2 = (Graphics2D)g;... }

CSE1720 Lecture 08; Week 05 Lecture 09 Second level Third level Fourth level Fifth level

Overview. Java2D. Graphics in Java2D: Colour Images Fonts. The bigger picture of Java Graphics: Java Advanced Imaging (JAI) API Java3D

03 Vector Graphics. Multimedia Systems. 2D and 3D Graphics, Transformations

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Java Programming. Computer Science 112

Creating Vector Shapes Week 2 Assignment 1. Illustrator Defaults

CSE111 Introduction to Computer Applications

Advanced Special Effects

Create Text Inside a Shape with Photoshop CS6

How to draw and create shapes

CSE115 Lab 4 Fall 2016

Creative Effects with Illustrator

SketchUp Help. 1 of 15 8/29/09 10:00 AM

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Using Flash Animation Basics

EEN118 LAB TWO. 1. A Five-Pointed Star.

JavaFX Technology Building GUI Applications With JavaFX - Tutorial Overview

Output models Drawing Rasterization Color models

Animated Gif - Illustrator /Text and Shapes

Topics. Transient vs Persistent Representation of Objects. Object Serialization CSE Lecture 9 Inheritance, III

MET 107 Drawing Tool (Shapes) Notes Day 3

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Class Meeting 04 (Lecture 03) Objectives for this class meeting

01 - Basics - Toolbars, Options and Panels

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

IS311 Programming Concepts J AVA. Abstract Window Toolkit. (part 2: Graphics2D)

A Step-by-step guide to creating a Professional PowerPoint Presentation

Graffiti Wallpaper Photoshop Tutorial

SketchUp. SketchUp. Google SketchUp. Using SketchUp. The Tool Set

1. Complete these exercises to practice creating user functions in small sketches.

Let s Make a Front Panel using FrontCAD

Graphics and Java 2D Introduction OBJECTIVES. One picture is worth ten thousand words.

6 Using Adobe illustrator: advanced

Creative Effects with Illustrator

An Introduction to Processing

Adobe Illustrator CS Design Professional GETTING STARTED WITH ILLUSTRATOR

IT101. Graphical User Interface

GUI Output. Adapted from slides by Michelle Strout with some slides from Rick Mercer. CSc 210

Microsoft PowerPoint Tutorial

Ai Adobe. Illustrator. Creative Cloud Beginner

MINT Interactive User s Guide

Shape and Line Tools. tip: Some drawing techniques are so much easier if you use a pressuresensitive

CS 200. Lecture 04. Geometric Graphics. (aka Vector Graphics) CS 200 Winter Geometric Graphics

CS 200. Lecture 04. Geometric Graphics. (aka Vector Graphics) Miscellaneous Notes

I-Carver CNC Project Computer Directions. Rob MacIlreith Last Update Oct 2017

Drawing Graphics in C Sharp

InDesign Tools Overview

CSC207H: Software Design Lecture 11

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

TWO-DIMENSIONAL FIGURES

@Override public void start(stage primarystage) throws Exception { Group root = new Group(); Scene scene = new Scene(root);

Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Tutorial 1 Engraved Brass Plate R

Google LayOut 2 Help. Contents

Basic Input and Output

CSE1720. General Info Continuation of Chapter 9 Read Chapter 10 for next week. Second level Third level Fourth level Fifth level

Adobe illustrator Introduction

Adobe PageMaker Tutorial

Faculty Development Seminar Series Constructing Posters in PowerPoint 2003 Using a Template

EECS 1001 and EECS 1030M, lab 01 conflict

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

IT82: Mul timedia. Practical Graphics Issues 20th Feb Overview. Anti-aliasing. Fonts. What is it How to do it? History Anatomy of a Font

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

Lesson 5: Review and Deliver Presentations Microsoft PowerPoint 2016 IN THIS CHAPTER, YOU WILL LEARN HOW TO

PowerPoint 2010 Quick Start to a Presentation

Working with Graphics and Text

Adobe Illustrator. Always NAME your project file. It should be specific to you and the project you are working on.

CISC 1600 Lecture 3.1 Introduction to Processing

Adobe Illustrator. Quick Start Guide

SOLIDWORKS: Lesson 1 - Basics and Modeling. Introduction to Robotics

Using Microsoft Word. Tables

Word 2007: Flowcharts Learning guide

Instructor s Notes Programming Logic Printing Reports. Programming Logic. Printing Custom Reports

Photoshop Introduction to The Shape Tool nigelbuckner This handout is an introduction to get you started using the Shape tool.

Paint Tutorial (Project #14a)

Learning Microsoft Word By Greg Bowden. Chapter 10. Drawing Tools. Guided Computer Tutorials

Using Microsoft Excel

Adding Objects Creating Shapes Adding. Text Printing and Exporting Getting Started Creating a. Creating Shapes Adding Text Printing and Exporting

ESCHERLIKE developed by Géraud Bousquet. User s manual C03-04 STROKE WIDTH C03-05 TRANSPARENCY C04-01 SAVE YOUR WORK C04-02 OPEN A FILE

Graphics and Painting

Drawing a Circle. 78 Chapter 5. geometry.pyde. def setup(): size(600,600) def draw(): ellipse(200,100,20,20) Listing 5-1: Drawing a circle

CS 200. Lecture 04. Geometric Graphics. (aka Vector Graphics) Geometric Graphics. CS 200 Fall 2014 Monday, September 29, 14

InDesign - Basic Spring Indesign. Setup a new document

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

Basic Input and Output

ActivInspire Layout and Tools Orientation

LinkMotion and CorelDraw 9, 10, 11, 12, X3, X4, X5, X6, X7 and X8:

This document should only be used with the Apple Macintosh version of Splosh.

SETTINGS AND WORKSPACE

Custom Shapes As Text Frames In Photoshop

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

Illustrator Domains 1-4: Getting to Know Your Workspace. Dreamweaver Domain 3

Basic Input and Output

InDesign Basics. Adobe

Transcription:

CSE1720 Click to edit Master Week text 02, styles Class Meeting 05 (Lecture 04) Second level Third level Fourth level Fifth level Winter 2013 Thursday, January 17, 2013 1 Objectives for this class meeting Conduct vote on basic style of game for class project this vote only determines the gist of the game; many aspect of the game we will refine and decide at subsequent steps Cover basic information on 2D Graphics we will need this for designing our game 2 1

Voting on the game you will each receive a ballot by email submit the ballot as follows submit 1720 Vote ballot.txt 3 Basic Graphics Suggested background reading: The Java Tutorials, Trail: 2D Graphics http://docs.oracle.com/javase/tutorial/2d/index.html These lecture slides provide a basic overview of that material, enough to get you started with the lab exercises 4 2

The Big Picture apps that use graphics must work with the Window Manager (WM)! the WM is part of any operating system (OS) that uses a desktop metaphor" the app requests a window from the window manager" the window manager ultimately decides whether a window is shown " user may minimize, overlap, maximize the windows on the desktop" the window manager tells the app what its screen real estate is at a given point in time" 5 The Big Picture if you want your app to draw some graphics, then you need to understand the following: There is a separation of concerns at work here! The app doesn t do the drawing. The app specifies what should be drawn (the WHAT), and then the WM/OS actually does the drawing (the HOW)" As the app developer, you need to understand this separation" 6 3

Graphics2D class services the Graphics2D object encapsulates the HOW part of the drawing" the complexity of the HOW is hidden from the clients" how to translate drawing coordinates to screen coordinates " which pixels need to be modified and how" all of the low level stuff that concerns graphics rendering 7 Graphics2D class services an app that has a window will be able to access the Graphics2D object that is associated with the window" console based apps cannot get access to a Graphics2D object there is no window!! The client (the app) uses the Graphics2D object to specify the WHAT --- a description of which graphic primitives are desired. The Graphics2D object, as part of its services, deals with getting those primitive rendered as computer graphics." 2D Graphic primitives include: basic geometric shapes, lines, arcs, text" 8 4

Graphics2D class services The client uses the methods of Graphics2D to specify the graphic primitives to be drawn a useful method is called draw it takes one argument, a Shape all of the graphic primitives can be provided, since Shape is the parent class The manner in which these primitives are rendered depends on the current values of several properties of the Graphics2D object. By manner we are talking about aspects such as the width and color of the lines." 9 Graphics2D class services The client specifies the graphic primitives to be drawn in user space (in coordinate units ) Graphics2D class services translates the coordinates in user space to coordinates in device space (in pixels) " Depending on the screen resolution, one point in user space may translate to several pixels in device space" Your app can invoke the following to determine the screen resolution in dots per inch: Toolkit.getDefaultToolkit().getScreenResolution() 10 5

Coordinate spaces From: http://docs.oracle.com/javase/tutorial/2d/overview/ coordinate.html" The Java 2D API maintains two coordinate spaces:" User space The space in which graphics primitives are specified" Device space The coordinate system of an output device such as a screen, window, or a printer" User space is:" a device-independent logical coordinate system. " the coordinate space that your program uses. " All geometries passed into Java 2D rendering routines are specified in user-space coordinates." 11 When it is time to render the graphics, a transformation is applied to convert from user space to device space. The origin of user space is the upper-left corner of the component s drawing area." Examples Construct a graphic primitive and draw it Rectangle2D.Double shape1 =!!!new Rectangle2D.Double(5, 15, 20, 50);! 20 units wide and 50 units high, as given in coordinate units. The upper left hand corner is anchored at (5,15) If your screen resolution is 72, then there will be 72 coordinate units per inch. But this can vary. The name of the class is weird there is a dot in the middle of it. Nevermind this for the moment! 12 6

Examples Now, the weirdly-named class is a sub-class of the class Rectangle2D So we can do this: Rectangle2D shape1 =!!!new Rectangle2D.Double(5, 15, 20, 50); And also the class Rectangle2D is a subclass of Shape So we can do this: Shape shape1 =!!!new Rectangle2D.Double(5, 15, 20, 50);! 13 Examples We haven t drawn anything yet! We need to tell the Graphics2D object that we want shape1 to be drawn. So we do this to obtain a reference to the Graphics2D object: Graphics2D graphicsobj = mypict.getgraphics(); (Assuming here that mypict is a Picture object) And then we tell the graphics2d object that we want shape1 drawn: graphicsobj.draw(shape1);! 14 7

Examples The rectangle is drawn with the current settings of the Graphics2D object. To change the colour of the pen (so to speak)! graphicsobj.setcolor(color.blue); graphicsobj.draw(shape1); graphicsobj.setcolor(color.red); graphicsobj.draw(shape1);! This draws a red rectangle on top of the blue rectangle Any shape that is drawn is drawn with the current settings until the settings change 15 Examples Note that there is no way to move rectangle. You can move the origin of the coordinate system up/ down or left/right this will make it appear as though the anchor of the rectange has moved this is not recommended at this point, since we want a fixed origin Instead, just instantiate new shapes with different anchor points 16 8

Examples Instead of drawing the outline of a shape, we can draw it as a filled shape! graphicsobj.setcolor(color.blue);! graphicsobj.fill(shape1);! 17 About transformations Once a shape is specified in user space, then any number of transformations can be applied to it For instance, here is a shear transformation of a rectangle There are also transformations to rotate and scale. 18 9

About State There are settings for several aspects of drawing:" The stroke width, the way the strokes are joined together, the appearance of the ends of lines" The current translation, rotation, scaling, and shearing values" The paint color" The fill pattern" 19 Since these aspects are controlled by attribute values, we say that the state of the Graphics2D object determines the drawing settings." Shape Primitives" 20 20" 10

Shape Primitives" ref: http://java.sun.com/developer/technicalarticles/gui/java2d/java2dpart1.html 21 21" About Stroke Stroke controls the width of the drawing pen The default width is 1 unit (typically 1 pixel wide, so it is teeny-tiny) Here s how to change it: BasicStroke newstroke = new BasicStroke(4.0);! graphicsobj.setstroke(newstroke);!! 22 Since Stroke is the parent class of BasicStroke, you can also write: Stroke newstroke = new BasicStroke(4.0);! graphicsobj.setstroke(newstroke);! 11

About Colour Paint controls the colour of the drawing pen The default width is WHITE Here s how to change it (older version): graphicsobj.setcolor(color.blue);!! Here s how to change it (newer, better version):! graphicsobj.setpaint(color.blue);!! 23 the setpaint method takes a Paint argument, and a Color object can fit the bill! Here is a fancier fill Point p1 = new Point(0, 0); Point p2 = new Point(50, 50); GradientPaint paint1 =!new GradientPaint(p1, Color.RED, p2, Color.MAGENTA, true); graphicsobj.setpaint(paint1);! Try it yourself! 24 12

To Do: Practise using all of these various methods and experiment on your own. Complete the lab exercises 25 13