IS 1014 Introduction to Computer Graphics -- Paul Munro A Postscript Tutorial Book available at: cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF.

Slides:



Advertisements
Similar presentations
Pages and boxes Building quick user interfaces. learning objectives o Build a quick UI with pages and boxes o understand how pages and boxes work o click.
Advertisements

 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 30 - Dynamic HTML: Structured Graphics ActiveX Control Outline 30.1Introduction 30.2Shape Primitives.
CHAPTER 20 CREATING SVG GRAPHICS. LEARNING OBJECTIVES How to embed a graphic stored within a.SVG file in an HTML page How to use the and tag pair to specify.
RAPTOR Syntax and Semantics By Lt Col Schorsch
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics.
Foundation Level Course
PZ14A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ14A - Text processing Programming Language Design and.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
2. Stack-based Programming Prof. O. Nierstrasz scg.unibe.ch.
C++ Graphics Primitives April 15th. void clearscreen(int c) –clear the screen to background color c –If c = 1 screen black.
R ESEARCH G ENOME B IOINFORMATICS L AB R ESEARCH at G ENOME B IOINFORMATICS L AB Josep F. Abril Ferrando and Genís Parra Farré Genome BioInformatics Research.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
First-Year Engineering Program 1AU 2006 Engineering H191 Engineering Fundamentals and Laboratory I Week 01 Day 01 Graphics: The Language of Design.
Engineering H191 Engineering Fundamentals and Laboratory I
3. Stack-based Programming. © O. Nierstrasz PS — Stack-based Programming 3.2 Roadmap Overview  PostScript objects, types and stacks  Arithmetic operators.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
INTRODUCTION TO PYTHON PART 5 - GRAPHICS CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Graphics in Android 1 Fall 2012 CS2302: Programming Principles.
Working with Graphics. Objectives Understand bitmap and vector graphics Place a graphic into a frame Work with the content indicator Transform frame contents.
SWHIG Seminar Ian Kim 1/18/12.  General overview of printing technology ◦ Background information:  Vector vs. raster graphics  How inkjet printers.
Development of PostScript Procedures for Transformations of Digital Typography Ph. D. Sc. Klaudio Pap, Ph. D. Sc. Vilko Žiljak Faculty of Graphic Arts,
PZ07A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ07A - Expressions Programming Language Design and Implementation.
Appendixes 4. An Introduction to PostScript ® CVG Lab.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 26 – CheckWriter Application Introducing Graphics.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Session: 17. © Aptech Ltd. 2Canvas and JavaScript / Session 17  Describe Canvas in HTML5  Explain the procedure to draw lines  Explain the procedure.
B.A. (Mahayana Studies) Introduction to Computer Science November March Logo (Part 2) More complex procedures using parameters,
Introduction to Flash. Topics What is Flash? What can you do with it? Simple animation Complex interactive web application, such as an online store. Starting.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Slide 1 Graphics Slide 2 Graphics A graphics package is a general purpose package used to draw pictures (graphics). Once produced, these can be saved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved CheckWriter Application Introducing Graphics and Printing.
Overview What is PostScript? Types Language Concepts Control Operators Examples.
Introduction to Using the Notebook 10 Software for SMART Board Day 2 LIVINGSTON PARISH PUBLIC SCHOOLS Facilitated by S. Waltman.
Lecture 16 Image Document Formats. Bitmap vs. Vector Images Bitmaps do not generally.
5. Assembly Language. Basics of AL Program data Pseudo-ops Array Program structures Data, stack, code segments.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
PZ07A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ07A - Expressions Programming Language Design and Implementation.
PZ07A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ07A - Expressions Programming Language Design and Implementation.
GRAPHICS MODULE 14 STUDY BOOK. Graphic commands SCREEN - puts the screen into graphics mode WINDOW - allows scaling of the screen LINE - 3 formats –LINE.
Text processing Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 12.1.
1 Expressions Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Expressions Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
1 Introduction to PostScript Sep. 21 Dae-Eun Hyun 3D MAP Lab.
Graphics in Android 1 CS7030: Mobile App Development.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
Adobe Illustrator CS Design Professional WITH ILLUSTRATOR GETTING STARTED.
12 Graphics and Java 2D™.
Data Representation.
Chapter 21 – Graphics/Tk Outline 21.1 Introduction 21.2 GD Module: Creating Simple Shapes 21.3 GD Module: Image Manipulation 21.4 Chart Module 21.5 Introduction.
Building Java Programs
Cyclic Arrow Diagram How to Create a in PowerPoint Transfer Execution
Building Java Programs
Page description language from Adobe
Graphics in Android Fall 2012 CS2302: Programming Principles.
Pages:51-59 Section: Control1 : decisions
Hour of Code.
Drawing Graphics in JavaScript
Repetition and Multiple Forms
Expressions Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Text processing Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 12.1.
Pages:51-59 Section: Control1 : decisions
Mod 2 Lesson 2 Repeating with loops
Expressions Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
The Isometric Grid. Page 21. The Isometric Grid. Page 21.
TITLE BYOT Half Circle (Advanced)
Expressions Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

IS 1014 Introduction to Computer Graphics -- Paul Munro A Postscript Tutorial Book available at: cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF Postscript as a page description language –like HTML –text position, orientation font, style –figures position, orientation scaling coordinates pen control (move, line) PS as a programming language – like C++ – stack commands arithmetic operators – loops and conditionals – lines and shapes

IS 1014 Introduction to Computer Graphics -- Paul Munro The Stack A piece of memory set aside for immediate processing Store (push), retrieve (pop) LIFO “Last In -- First Out” Example: Postscript stack

IS 1014 Introduction to Computer Graphics -- Paul Munro Stacks are not just for numbers a line of postscript code -- all objects that are not operators go onto the stack: mark /Font [1 2] (PS) (PS) [1 2] /Font mark

IS 1014 Introduction to Computer Graphics -- Paul Munro Stack Arithmetic add add mul mul div 3 5 add div add

IS 1014 Introduction to Computer Graphics -- Paul Munro Arithmetic Operators div idiv mod mul neg add sub 5 2 div = 5 2 idiv = 5 2 mod = 5 2 mul = 5 neg = 5 2 add = 5 2 sub =

IS 1014 Introduction to Computer Graphics -- Paul Munro Stack Operators CBACBA clear CCBACCBA CBACBA dup BCABCA CBACBA exch BABA CBACBA pop

IS 1014 Introduction to Computer Graphics -- Paul Munro Graphics in Postscript construct a path on the current page coordinates are in points (72 pt = 1 inch) (0,0) is the lower left corner of the page newpath begins a path description moveto, rmoveto move the pen (up) lineto, rlineto draw with the pen (down) stroke places the marks on the virtual paper showpage renders the marks

IS 1014 Introduction to Computer Graphics -- Paul Munro An example (0,0) newpath moveto rlineto moveto rlineto stroke showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro Another example (a box) newpath moveto 0 72 rlineto 72 0 rlineto rlineto rlineto 4 setlinewidth stroke showpage closepath

IS 1014 Introduction to Computer Graphics -- Paul Munro Filled Shapes (a filled box) newpath moveto 0 72 rlineto 72 0 rlineto rlineto closepath fill showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro A shaded box newpath moveto 0 72 rlineto 72 0 rlineto rlineto closepath.5 setgray fill showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro A buncha boxes newpath %Begin black box moveto 0 72 rlineto 72 0 rlineto rlineto closepath fill newpath %Begin gray box moveto 0 72 rlineto 72 0 rlineto rlineto closepath.4 setgray fill newpath %Begin lighter box moveto 0 72 rlineto 72 0 rlineto rlineto closepath.8 setgray fill showpage %Send to printer

IS 1014 Introduction to Computer Graphics -- Paul Munro Path Construction Operators closepath Closes the current path with a straight line to the last moveto point x y lineto Continue the path with line to (x,y) x y moveto Set the current point to (x,y) newpath Clear the current path x y rlineto Relative lineto (currentpoint + (x,y)) x y rmoveto Relative moveto

IS 1014 Introduction to Computer Graphics -- Paul Munro Painting Operators fill Fill current path with the current color n setgray Set the current color n setlinewidth Set the current line width stroke Paint the current path with the current color and line width An Output Operator showpage Transfer the current page to the output device

IS 1014 Introduction to Computer Graphics -- Paul Munro Variables /ppi 72 def 5555 ppi 72 5 mul ppi mul example:

IS 1014 Introduction to Computer Graphics -- Paul Munro Procedures In Postscript, procedure definitions use the same syntax as variable definitions: /inch {72 mul} def whenever “inch” appears, it is replaced with “72 mul” 6 inch => 6 72 mul => 432 example:

IS 1014 Introduction to Computer Graphics -- Paul Munro Three Boxes Again % Begin Program newpath % First box moveto box 0 setgray fill newpath % Second box moveto box.4 setgray fill newpath % Third box moveto box.8 setgray fill showpage %Black box newpath moveto 0 72 rlineto 72 0 rlineto rlineto closepath fill %Gray box newpath moveto 0 72 rlineto 72 0 rlineto rlineto closepath.4 setgray fill %Begin lighter box newpath moveto 0 72 rlineto 72 0 rlineto rlineto closepath.8 setgray fill % Define box procedure --- /box { 72 0 rlineto 0 72 rlineto rlineto closepath } def

IS 1014 Introduction to Computer Graphics -- Paul Munro Three Boxes Yet Again % Define procedures---- /inch {72 mul} def /box % stack: x y => --- { newpath moveto 1 inch 0 rlineto 0 1 inch rlineto -1 inch 0 rlineto closepath } def /fillbox % stack: grayvalue => --- { setgray fill } def % Main Program inch 4.5 inch box 0 fillbox 3.75 inch 5 inch box.4 fillbox 4 inch 5.5 inch box.8 fillbox showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro Translating Space translate

IS 1014 Introduction to Computer Graphics -- Paul Munro Translation example /square %procedure to draw a { newpath % filled square 0 0 moveto 90 0 lineto %define a square path lineto 0 90 lineto closepath fill %fill it } def square %do a square translate %move coord. sys. square %do another square translate %and move again square %do a third square showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro Rotation 45 rotate this statement will rotate the user coordinate system 45 degrees:

IS 1014 Introduction to Computer Graphics -- Paul Munro Rotation Example /square %procedure from { newpath % previous program 0 0 moveto 90 0 lineto lineto 0 90 lineto closepath fill 6 92 moveto %Label the box } def square %do a square translate %move coord. sys. 60 rotate %and rotate it square %do it again translate 60 rotate square %do a third square showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro Scaling The scale operator rescales the two coordinate axes scale

IS 1014 Introduction to Computer Graphics -- Paul Munro Scaling example /square %procedure to draw a { newpath % filled square 0 0 moveto 90 0 lineto lineto 0 90 lineto closepath fill 6 92 moveto %Label the box } def square %do a square translate scale square translate scale %non-uniform scaling square showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro Conditionals and loops eq ne lt gt le ge if ifelse loop exit for

IS 1014 Introduction to Computer Graphics -- Paul Munro if bool {commands} if /chkforendofline { currentpoint pop %get x-position 612 gt %greater than 612? {0 -12 translate 0 0 moveto} if } def

IS 1014 Introduction to Computer Graphics -- Paul Munro if else % Variables & Procedures /scalefactor 1 def /counter 0 def /DecreaseScale { scalefactor.2 sub /scalefactor exch def } def /IncreaseCounter { /counter counter 1 add def } def /trappath %construct a trapezoid { 0 0 moveto 90 0 rlineto rlineto rlineto closepath } def /doATrap { gsave 1 scalefactor scale %scale vert. axis trappath %construct path counter 2 mod %is counter even? 0 eq {.5} {0} ifelse %choose grey or black setgray fill grestore } def %restore scale, etc. % Begin Program translate 5 {IncreaseCounter doATrap DecreaseScale 0 20 translate } repeat showpage bool {cmds A} {cmds B} ifelse

IS 1014 Introduction to Computer Graphics -- Paul Munro loop { cmds } loop /pagewidth mul def /doCircle { xpos ypos radius arc stroke} def /increase-x { xpos radius add /xpos exch def } def 7.2 LOOPS 69 /lineofcircles %stack: radius y { /ypos exch def %define ypos /radius exch def %...& radius /xpos 0 def %...& xpos {xpos pagewidth le %begin loop {doCircle increase-x} {exit} ifelse }loop %end loop } def %end definition % Begin Program lineofcircles lineofcircles lineofcircles showpage

IS 1014 Introduction to Computer Graphics -- Paul Munro for a inc b {cmds} for % Define box procedure --- /box { 72 0 rlineto 0 72 rlineto rlineto closepath } def moveto {rmoveto box} showpage