1 / 12

Pslib Manual

Pslib Manual. PSlib. Pslib is a library for making “postscript (ps)” file. Postscript is a language for supporting the high-quality printer. Postscript language is developed by Adobe Inc. Postscript Language.

kuhnc
Télécharger la présentation

Pslib Manual

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pslib Manual

  2. PSlib • Pslib is a library for making “postscript (ps)” file. • Postscript is a language for supporting the high-quality printer. • Postscript language is developed by Adobe Inc.

  3. Postscript Language • Postscript language is widely used in many environment to support the printer or for making high-quality documents. • The syntax of the postscript language is very simple and you can find many on-line tutorial about it. • You don’t have to learn the postscript language grammar to use the Pslib, but, if you are interested in the syntax and more about the postscript, you can refer to the following links: • http://www.cs.indiana.edu/docproject/programming/postscript/postscript.html • http://www-ph.postech.ac.kr/material/comp/Software/POSTSCRIPT/ • http://astronomy.swin.edu.au/~pbourke/geomformats/postscript/ • http://www.mactech.com/articles/mactech/Vol.09/09.04/PostscriptTutorial/ • postscript language cookbook pdf ( I think this is illegal because the book is a commercial product, but, anyway, if you want…): http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF

  4. Viewing Postscript File • For viewing or printing a postscript file, you should install the following products: • Ghostscript • GSview • The above two software products can be freely downloaded from: http://www.cs.wisc.edu/~ghost/ • Note that the latetest version of the Ghostscript is 8.11 and that of GSview is 4.4 (Sep. 23, 2003). • After the installations, you can test your “Gsview” by double-clicking “demo1/test.ps” file. • If you have any problem to install the above two softwares, please let me know (iklee@yonsei.ac.kr)

  5. DEMO1 • Demo1 for Pslib is a “console” program. • You don’t have to add any extra include directories or link any extra libraries. • Start the demo1 project by clicking Pslib.dsw file.

  6. Source Files • Demo1 project consists of one header file (pslib.h) and two cpp files (demo.cpp and pslib.cpp). • pslib.h and pslib.cpp • library source • You don’t have to change anything in these two files. • demo.cpp • explaining how to use the pslib functions.

  7. demo.cpp - 1 #include <iostream.h> #include "pslib.h" int main() { cPSLib myps("test.ps"); • You should include “pslib.h” • The cPSLib instance is made by using a constructor which is called with a “ps file name” parameter. • Now, your further output in the program will be written into the ps file “test.ps”.

  8. demo.cpp - 2 float minx, miny, maxx, maxy; minx = -100.0f; maxx = 400.0f; miny = -100.0f; maxy = 700.0f; // fit the regions to A4 myps.FitA4(minx, miny, maxx, maxy); • At first, we define the boundary of the drawings. • We can make the boundary using PSlib::FitA4(…) function. • Parameters: minx, miny, maxx, maxy • Then, the drawing area is scaled to the given boundary.

  9. demo.cpp - 3 • Why A4Fit? • Sometimes, you want to draw some objects (lines, circles, …) having very general coordinates. • The default size of A4 paper for the postscript is 595 x 842. • That is, the default x coordinate range is [0..595], and y coordinate range is [0..842]. • If you want to draw some point set in [-300..900] x [300..1200], then you can fit the drawing area into the A4 paper using the function call: myps.FitA4(-300, 300, 900, 1200); • Note that this “FitA4” call should be made BEFORE ANY OTHER DRAWINGS in the ps file.

  10. demo.cpp - 4 // bounding box float tx[4], ty[4]; tx[0] = minx; ty[0] = miny; tx[1] = minx; ty[1] = maxy; tx[2] = maxx; ty[2] = maxy; tx[3] = maxx; ty[3] = miny; myps.DrawPolygon(tx, ty, 4, 0, 1.0f); • DrawPolygon(xarray, yarray, num_points, fill_tag, width, color) • can draw the the “closed polygon” • Use “fill_tag = 1” for filling the polygon (if fill_tag = 0, no filling) • Use “width” for controlling the width of the line (any positive real val) • Use “color” for controlling the gray level of the color • 0: black, 1: white, 0~1: gray value

  11. demo.cpp - 5 • Draw a line (x1,y1) – (x2,y2) DrawLine(float x1, float y1, float x2, float y2, float width=1.0f, float color=0.0f); • Draw a circle at center (cx, cy) with radius “radius”. DrawCircle(float cx, float cy, float radius, int fill=0, float width=1.0f, float color=0.0f); • Show a test string “Text” at (x, y) DrawText(float x, float y, char *Text, int Scale=12, float color=0.0f);

  12. demo.cpp - 6 • After all drawings, you should call “myps.CloseFile()”.

More Related