FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   SimplePostscript - Postscript output from P5
« Previous topic | Next topic »

Pages: 1 2 
   Author  Topic: SimplePostscript - Postscript output from P5  (Read 4371 times)
amoeba

WWW
SimplePostscript - Postscript output from P5
« on: Jan 7th, 2004, 5:17pm »

I've just put a simple library that I call SimplePostscript online for download. It allows you to output Postscript from inside Processing, just download the .class file and put it in the "code" folder of your sketch.  
 
It's not terribly well documented, and is strictly use-as-is. Sample Processing code and links to online Postscript resources are included. The Javadoc documentation for the class is online, and in case anyone wants to extend it the Java file is also available for download.
 
Hope this is useful. Let me know if you do anything interesting with it.
 
------
 
Update: I've posted some sample code that uses SimplePostscript to draw to Processing and Postscript at the same time. See this thread. I recently used this technique to do hi-res prints for a magazine article, see these images.
« Last Edit: Mar 11th, 2004, 1:25pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
toxi

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #1 on: Jan 7th, 2004, 7:08pm »

hey marius, this is great & very elegant! just had to stop work & give it a go myself...
 
Code:
SimplePostscript ps;
 
void setup() {
  size(200,200);
  ps=SimplePostscript.open("pattern.ps",0,0, 200,200);
}
 
void draw() {
  background(255);
  stroke(0);
  ps.setlinewidth(0.25);
  ps.setgray(0);
  int step=2;
  for(int y=0; y<height; y+=step) {
    beginShape(LINE_STRIP);
    for(int x=0; x<width; x+=step/2) {
 float z=y+calc(x,y);
 vertex(x,z);
 if (x==0) ps.moveto(x,z);
 else ps.lineto(x,z);
    }
    endShape();
    ps.stroke();
  }
  ps.close();
}
 
float calc(float x,float y) {
  return 10*(sin(x*0.1)*cos((y+x*0.33)*0.1));
}

 
looks nice as A4 printout @ 300dpi. obviously, postscript is not new, but... arrrgh, the possibilities...
 

http://toxi.co.uk/
TomC

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #2 on: Jan 7th, 2004, 8:28pm »

Could this be retrospectively written from the display, as with SimonG's DXFWriter?
 
Is the internal graphics class documented anywhere publicly, so we could give it a go?
 
pitaru

WWW Email
Re: SimplePostscript - Postscript output from P5
« Reply #3 on: Jan 7th, 2004, 8:53pm »

Marius - this library is wonderful, thank you so much!
 
Your java code gave me a great postscript overview!
 
looking forward to using it soon! Thanks again.
 
cheers.
amit
« Last Edit: Jan 7th, 2004, 8:53pm by pitaru »  
amoeba

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #4 on: Jan 7th, 2004, 10:58pm »

on Jan 7th, 2004, 8:28pm, TomC wrote:
Could this be retrospectively written from the display, as with SimonG's DXFWriter

 
Well, you can access the triangles as Simon demonstrated. But since Postscript is 2D you'd need to project them from 3D down to 2D, as well as sort them or do hidden-line removal. A proper headache if you want it done properly. I wonder if Ben already has done something like this. Ben
 
on Jan 7th, 2004, 8:53pm, pitaru wrote:
Your java code gave me a great postscript overview!

Thanks! I put in most of the functionality that is related to drawing stuff. Keep in mind that Postscript is actually a programming language, so there's plenty of other things to play with.  
 
One fun thing is to define functions to manipulate typography, for instance by using the "kshow" operator rather than the normal "show". "kshow" allows you to define a procedure that will be called between every character that is drawn, so that you can change the current path etc. Defining your own Type 3 font is also good, but I haven't put any code for anything like that in the library.
 
I would write an AI import module, except it's not much use as long as Processing doesn't render filled beziers very well. I guess the hack would be to use Java2D (which is based on Adobe technology), but then the applet export breaks...
« Last Edit: Jan 7th, 2004, 11:07pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
mKoser

WWW Email
Re: SimplePostscript - Postscript output from P5
« Reply #5 on: Jan 8th, 2004, 11:35am »

what else can I say: YUM!
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
Koenie

170825270170825270koeniedesign WWW Email
Re: SimplePostscript - Postscript output from P5
« Reply #6 on: Jan 11th, 2004, 9:33pm »

What's with the BoundingBox and the HighresBoundingBox? What does it do?
 
Koenie
 

http://koeniedesign.com
amoeba

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #7 on: Jan 13th, 2004, 1:26pm »

on Jan 11th, 2004, 9:33pm, Koenie wrote:
What's with the BoundingBox and the HighresBoundingBox What does it do

 
If I remember correctly they're actually from the EPS file format. They set the bounding boxes of your document. Illustrator etc. might choose to ignore shapes that fall completely outside this boundary.
 
When SimplePostscript writes the header it actually tells Illustrator to treat the file as an EPS, which has no effect except for %%BoundingBox or similar EPS comments.
 
marius (currently preaching Processing to HyperWerk students)
 

marius watz // amoeba
http://processing.unlekker.net/
zach


Re: SimplePostscript - Postscript output from P5
« Reply #8 on: Jan 14th, 2004, 8:44am »

hi marius,
 
looks great! &
hope you are having a great time in basel
 
for some ps info - please check out a page (forgive the typos!) and some examples -including some maeda knock offs - I've compiled:
 
http://thesystemis.com/dbn/
 
I taught this course along time ago and down at the middle of the page is some postscript info including a dictionary and some good, simple examples of writing straight postscript code.
 
postscript is a fun language to program in - very diff. then java.  the stack concept takes some getting used to, but then again, processing uses stacks for graphics transformations.  in ps everything is on a stack, including your arguments. so instead of saying something like 10 * (20 / 4) you say 10 4 20 div mul.  alot like reverse polish notation for all the math dorks out there.
 
also don't forget gsview/ghostscript as a viewer:
 
http://www.cs.wisc.edu/~ghost/
 
- z  
 
amoeba

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #9 on: Jan 14th, 2004, 11:19am »

hi zach,
 
on Jan 14th, 2004, 8:44am, zach wrote:
for some ps info - please check out a page (forgive the typos!) and some examples -including some maeda knock offs - I've compiled:
 
http://thesystemis.com/dbn/

 
thanks - I already put links to your info and to Ghostscript/Ghostview on the SimplePostscript page a few days ago. the Postcript tutorials are good for learning it as a language, SimplePostscript is mostly just for output as a static image.
 
I like the Postscript examples. I once taught a workshop only programming in Postscript, and it was a bit of a challenge to get people used to it. I remember seeing a Mandelbrot program written in Postscript that would print out a grayscale plot of the Mandelbrot set. Nerdy, but fun.
« Last Edit: Jan 14th, 2004, 11:21am by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
zach


Re: SimplePostscript - Postscript output from P5
« Reply #10 on: Jan 14th, 2004, 6:56pm »

doh!
 
that's called - post first read second....
 
checked out your site & saw the links.  
big thanks for putting all that together, very helpful stuff. zach
 
mr.prufrock

WWW Email
Re: SimplePostscript - Postscript output from P5
« Reply #11 on: Feb 6th, 2004, 8:28pm »

This is an excellent library, thanks amoeba!
 
Can't wait to try it out
 

I grow old...I grow old
I shall wear the bottoms of my trousers rolled.
amoeba

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #12 on: Feb 17th, 2004, 3:57pm »

I have moved SimplePostscript to my new processing.unlekker.net sub-site.
 
For more PostScript stuff, I recommend this interview with Glenn Reid who wrote the book "Thinking in PostScript". He graciously makes that book available for download as PDF from  Right Brain Software.
« Last Edit: Feb 17th, 2004, 3:58pm by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
19hrs

Email
Re: SimplePostscript - Postscript output from P5
« Reply #13 on: Feb 19th, 2004, 4:22pm »

hey amoeba, is your site offline?
« Last Edit: Feb 19th, 2004, 7:07pm by 19hrs »  

19hrs!
http://newsnewsnewsnews.net
amoeba

WWW
Re: SimplePostscript - Postscript output from P5
« Reply #14 on: Feb 20th, 2004, 9:48am »

not to my knowledge. all three sites are working as of this minute.
 

marius watz // amoeba
http://processing.unlekker.net/
Pages: 1 2 

« Previous topic | Next topic »