PostScript Internals Graphics II Spring 1999

Similar documents
Roadmap for tonight. What are Bezier curves (mathematically)? Programming Bezier curves (very high level view).

Programming Languages Third Edition. Chapter 7 Basic Semantics

How to draw and create shapes

Hello world. 2. Stack-based Programming. Oscar Nierstrasz

Informatique Graphique. Traitement de l'information et automatisation. Traitement de l'information et automatisation

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Functional Programming. Pure Functional Programming

PART I GravoStyle5-Laser Introduction

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CHAPTER 1 Graphics Systems and Models 3

Language Reference Manual simplicity

A Short Introduction to PDF

Mapbox Vector Tile Specification 2.0. Blake Thompson - Software Engineer, Mapbox

1 Lexical Considerations

Computer Graphics. - Rasterization - Philipp Slusallek

Einführung in Visual Computing

Package epsdice a scalable dice font

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

Font information interchange -- Part 3: Glyph shape representation Amendment 2: Additional Shape Representation Technology for Open Font Format

CS201 - Introduction to Programming Glossary By

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

Names, Scope, and Bindings

COMP371 COMPUTER GRAPHICS

An Introduction to Trees

Text and Graphics. Postcript is a Page Description Language! Paths

Postscript Intro. References. What is Postscript? Hello World! in Ghostscript. CSE 413, Autumn 2005 Programming Languages. Page description language

Short Notes of CS201

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Graphics (Output) Primitives. Chapters 3 & 4

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

12 APPLYING EFFECTS. Lesson overview

Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

PostScript: An Overview

Introduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms

The SPL Programming Language Reference Manual

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS 360 Programming Languages Interpreters

SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2. Assignment due Thursday, October 19, 11:59pm

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Chapter 8: Implementation- Clipping and Rasterization

Guile-GNOME: Libgnomecanvas

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

Adobe Photoshop Sh S.K. Sublania and Sh. Naresh Chand

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Watershed Sciences 4930 & 6920 GEOGRAPHIC INFORMATION SYSTEMS

Postscript Control Flow

Display PostScript System

CMSC 330: Organization of Programming Languages

Array. Prepared By - Rifat Shahriyar

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

Types II. Hwansoo Han

Names, Scope, and Bindings

CS 415 Midterm Exam Spring 2002

ADOBE ILLUSTRATOR CS3

The PCAT Programming Language Reference Manual

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Graphics Hardware and Display Devices

OpenPrinting Vector Printer Driver Application Program Interface (OPVP) Specification Version 1.0 September 27, 2010.

Introduction to Programming Using Java (98-388)

EF432. Introduction to spagetti and meatballs

Ruby: Introduction, Basics

Display PostScript System

CSC 467 Lecture 13-14: Semantic Analysis

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

Ū P O K O O T E I K A A M Ā U I U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2014 TRIMESTER 1 *** WITH SOLUTIONS ***

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011

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

CS5363 Final Review. cs5363 1

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Primitive Data Types: Intro

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Clipping. CSC 7443: Scientific Information Visualization

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

Institutionen för systemteknik

COMPUTER APPLICATION

Understanding Geospatial Data Models

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

EF432. Introduction to spagetti and meatballs

Computer graphics 2 Marks 1. Define Computer graphics.

Tokens, Expressions and Control Structures

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

Font Remix Tools Getting started

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

Principles of Compiler Design

Massachusetts Institute of Technology. Department of Computer Science and Electrical Engineering /6.866 Machine Vision Quiz I

Data Structures and Algorithms

-The Hacker's Dictionary. Friedrich L. Bauer German computer scientist who proposed "stack method of expression evaluation" in 1955.

RASTERIZING POLYGONS IN IMAGE SPACE

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

Transcription:

PostScript Internals 15-463 Graphics II Spring 1999

Background PostScript raster image processor for Mac All Level 1 features Some support for color and multi-bit devices Undergrad independent study: MacRIP Commercial product: TScript Sold by TeleTypesetting Co. Still around (!) 2

PostScript Features Device/resolution independence Orthogonality Vector shapes, images, text treated uniformly e.g. transforms and clips images and text Composability Complete language High-quality outline fonts 3

Focus Level1 implementation Level 2 adds many complex features Level 3 adds even more Laser printer-like output device One bit per pixel Medium resolution: ~300 dpi 2400x3000 pixels on a page = 1Mb frame buffer Non-interactive/batch model 4

Topics Language Overview Language Implementation Graphics Overview Scan Conversion and Clipping Fonts Images and Halftones 5

Language Overview

Syntax Stream of tokens with little structure Postfix notation No precedence, lexical scope, etc. Tokens Integer and real: 3 4.0 5e6 String: (Call the doctor.) Name: John yaya 3plus4 ==proc Procedure: {add 2 div} 7

More Object Types Array: vector of arbitrary objects Dictionary:finite mapping on objects Operator: built-in procedure Boolean: true and false Null Mark 8

Stacks Operand stack: accumulates arguments Execution stack: object to evaluate next Dictionary stack: explicit variable scope Types checked at run time All objects have an inherent type 9

Object Attributes Literal: push to the operand stack Executable Name: look up on dictionary stack Array: execute elements in order String: parse and execute code Operator: execute built-in operation Access unlimited > read-only > execute-only > none 10

Virtual Memory Virtual memory is just the allocation heap save snapshots all mutable objects Strings, arrays, dictionaries restore returns virtual memory to a previous snapshot All intervening mutations are undone Throw away all new objects Good for batch processing model 11

Language Implementation

Object Representation struct object { unsigned short type:4, exec:1, access:2; unsigned short length; union { int integer; float real; unsigned char *string; struct name *name; struct object *array; struct dict *dict; unsigned int operator; int boolean; } u; }; 13

Dictionary Representation Typically a hash table based on keys Corresponding values in parallel array struct dict { unsigned int access; unsigned short length; unsigned short maxlength; struct object *keys[maxlength]; struct object *values[maxlength]; }; 14

Name Representation Typically a global hash table for all names Cache with current binding for fast lookup struct name { struct name *next; struct object cache; unsigned short hash; unsigned short length; unsigned char string[length]; }; 15

Implementing Virtual Memory Allocate objects linearly from a large arena save remembers current allocation pointer restore resets allocation pointer What about mutated values? Could just block copy active heap: slow! Better to save location on first modification restore just walks through the undo list 16

Graphics Overview

Path Sequence of line and curve segments Need not be connected or closed Connected sequences of segments are subpaths Specified by path elements moveto starts a new, disconnected subpath lineto specifies a connected line curveto specifies a connected, cubic closepath connects an open subpath to its start 18

Graphics State Collects parameters for graphics operators Operators implicitly refer to current gstate Saved and restored by gsave and grestore Some specific parameters Current matrix allows affine transformations Current color is color to paint with Current path is shape to fill or outline Current clipping path restricts painted area Current font determines appearance of text 19

Graphics Operators fill paints inside of current path Uses non-zero winding number rule Permits arbitrary self-intersections Implicitly closes all open subpaths stroke outlines current path image renders a rectangular pixmap show renders a string using current font 20

Scan Conversion and Clipping

Flattening Curves Flattening approximates curves by lines Current flatness parameter limits deviation (in pixels) from true curve flattenpath flattens current path (in place) Recursive subdivision can work well Forward differencing has a faster inner loop x[t+1] = x[t]+dx[t] dx[t+1] = dx[t]+ddx[t] ddx[t+1] = ddx[t]+dddx[0] 22

Approximating Circular Arcs Arcs are approximated by cubic Required, since user can iterate over paths Some affine transformations of arcs are not arcs Each arc segment Control points are along tangents to arc F = (4/3)(1/(1+sqrt(1+(d/r)^2))) 23

Filling Flattened Paths Can use active edge lists (Foley+van Dam) Linear DDA doesn t need edge structures clear x transition lists loop curve segments in current path loop t using curve DDA loop y using line DDA store x coordinate on transition list for y repeat for clip path sort transition lists fill intersection of inside intervals according to rule 24

Stroking Flattened Paths Stroke of a path is a path itself Precise specification of line shape Current line width Current line join Current line cap strokepath replaces path with its stroke Special case for rendering zero-width lines 25

Clipping Flattened Paths clip intersects current path and clip path Computes polygon intersections Scan convert path and clip in parallel Use interior of both paths for rasterization Can generate trapezoids from modified scan converter Sample at segment extrema and intersections Reconstruct original segments, where possible 26

Fonts

Font Representation Fonts come in two flavors Type 1 are condensed path descriptions Type 3 are ordinary PostScript programs Font matrix defines character coordinates Font encoding maps character codes to character names Font cache retains bitmaps for most commonly used characters 28

Type 3 BuildChar Algorithm: Check font cache for character mask Concatenate font matrix with current matrix Call BuildChar with font dictionary and character code Save bits in font cache, if appropriate Typical BuildChar procedure: Look up character name in Encoding vector Set character width and bounding box Construct path for character outline fill 29

Type 1 Font Hints Tunes rasterizer at low resolutions Blue values declare standard heights of character features (from baseline) Stem width hints declare standard widths of character features Character stem hints identify stems in character outlines 30

Interpreting Font Hints All feature heights for a given blue value are rounded consistently Fuzz parameter is slop for matching heights All standard stem widths are rounded consistently Overshoot suppression gives flat and round characters same height Flex feature straightens shallow curves 31

Images and Halftones

Images image specifies absolute color values imagemask pours color through a stencil Matrix specifies pixel coordinate system Procedure supplies pixel/bitmap values 33

Image Rendering Reverse sample through inverted matrix Scan convert clip path as additional mask Use anti-aliasing for multi-bit devices 34

Halftones Laser printers can t place pixels in isolation => Can t use standard dithering techniques Frequency specifies cells per inch Angle specifies orientation of grid lines Spot procedure determines shape of cells Circular spots are typical Example: 60 lpi = 25 grays at 300 dpi 35

Halftone Rendering Offset cells into a repeating tile Usually, only discrete angles are available Call spot function on pixel centers Set n pixels with least spot values n = round((1-gray_level)*spot_area) 36

Extensions Multi-bit devices Level 2 Forms and patterns Color spaces User paths and graphics states Display PostScript Concurrency View clip 37

References Adobe PostScript Language Reference Manual (Second Edition) Adobe Type 1 Font Format Tutorial on Forward Differencing, Bob Wallis, Graphics Gems I Fast Scan Conversion of Arbitrary Polygons, Bob Wallis, Graphics Gems I 38