Overview of Item Types
Kpl is a language (designed at New York University by Ken Perlin, et. al.) that is very simple, but extremely fast. It is the best language we found for writing interpreted code for rendering quickly. In fact, Kpl has a byte-compiler which makes it faster. Some simple experiments have shown it to be roughly 15 times slower than C for simple math (compared to tcl which is typically about 1,000 times slower than C). Because Kpl is a general-purpose language, it can be used for on-the-fly calculations as well as render calls. Pad++ supplies several render that available through Kpl that allow a Kpl object to render fairly complex objects.
Kpl is a stack-based post-fix language (much like PostScript). Some basic documentation is available with the Pad++ release in doc/kpl.troff. See the section in this document on the KPL-PAD++ INTERFACE for a description of how to access Kpl through Pad++, and what Pad++ routines are available from Kpl.
Kpl items are created with widget commands of the following form:
pathName create kpl [option value option value ...]There may be any number of option-value pairs, each of which sets one of the configuration options for the item. These same option-value pairs may be used in itemconfigure widget commands to change the item's configuration. The following special options are supported for kpl objects:
-bb [9]
A KPL script that gets evaluated to specify the bounding box of an item
# Tcl code to load Kpl code and to create # Pad++ Kpl item that draws a brown triangle kpl eval 'triangle.kpl source set pen [.pad alloccolor brown] .pad create kpl -bb {-10:-10 110:110} -renderscript {draw_triangle} /* Kpl code (in a separate file) to draw a brown triangle */ { 'pen tcl_get -> Pen Pen setcolor 3 setlinewidth newpath 0:0 moveto 100:0 lineto 50:100 lineto 0:0 lineto stroke } -> draw_triangle
Copyright Computer Science Department, The University of New Mexico