Mediascripting on the Web (CSC 195 2014F) : EBoards

CSC 195 2014S, Class 04: PostScript


Overview

Preliminaries

Admin

What you learned about Processing ...

PostScript basics

Important drawing commands

Program control

Sample procedures

Sample Code

How Sam Draws Rectangles

% left bottom width height rect
%   Draw the specified rectangle.
/rect {     % l b w h
  4 2 roll  % w h l b
  moveto    % w h
  1 index   % w h w
  0         % w h w 0
  rlineto   % w h
  dup       % w h h
  0 exch    % w h 0 h
  rlineto   % w h
  exch      % h w
  neg 0     % h -w 0
  rlineto   % h
  neg       % -h
  0 exch    % 0 -h
  rlineto   % 
  stroke    % 
} def

Right-justifying text

% string showright
/showright {    % str 
  dup           % str str
  stringwidth   % str str-width str-height
  pop           % str str-width
  neg           % str -str-width
  0             % str -str-width 0
  rmoveto       % str 
  show
} def

Why study PostScript?

Lab

or

or

Copyright (c) 2014 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.