Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== plot An interface to the GNU libplot library. [[toc:]] == Usage (import plot) == Documentation {{libplot}} is a part of the [[http://www.gnu.org/software/plotutils/|GNU plotutils]] package. It is a 2-D vector graphics library capable of exporting to many file formats, both vector and raster. The Chicken {{plot}} library provides a Scheme interface to a large subset of the {{libplot}} procedures. This interface follows closely the {{libplot}} API, so the main reference is the [[http://www.gnu.org/software/plotutils/manual/en/index.html|plotutils]] manual. In {{libplot}}, function names are of the form {{pl_function_r}}. The Scheme corresponding function name is {{function}}. Below is a list of procedures that are included in this egg, along with brief descriptions. This egg has been tested with {{plotutils}} version 2.6. === Version Information <procedure>(libplot-version) → string</procedure> Returns the version string of the underlying libplot library. === Data Types and Constructors ==== Plotter Types <record>plotter-type</record> An algebraic datatype representing the type of plotter to create. Each plotter type corresponds to a different output format. Constructors include: ; {{(X)}} : X Window System display ; {{(PNG)}} : Portable Network Graphics (raster) ; {{(PNM)}} : Portable Anymap format (raster) ; {{(GIF)}} : Graphics Interchange Format (raster) ; {{(SVG)}} : Scalable Vector Graphics (vector) ; {{(AI)}} : Adobe Illustrator format (vector) ; {{(PS)}} : PostScript (vector) ; {{(CGM)}} : Computer Graphics Metafile (vector) ; {{(FIG)}} : XFIG format (vector) ; {{(PCL)}} : HP PCL format ; {{(HPGL)}} : HP-GL/2 format (vector) ; {{(REGIS)}} : ReGIS graphics format ; {{(TEK)}} : Tektronix format ; {{(META)}} : GNU metafile format (vector) <procedure>(plotter-type? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a plotter-type value, {{#f}} otherwise. ==== Plotter Parameters <record>plotter-parameter</record> An algebraic datatype representing configuration parameters for plotters. Each constructor takes one or more arguments to specify the parameter value. '''Common Parameters (apply to most or all plotter types):''' ; {{(DISPLAY string)}} : X Window System display name (X plotter only) ; {{(BITMAPSIZE string)}} : Size specification for bitmap plotters (e.g., "800x600") ; {{(PAGESIZE string)}} : Page size for vector plotters (e.g., "letter", "A4", "11x17in") ; {{(ROTATION string)}} : Rotation angle in degrees (e.g., "0", "90", "180", "270") ; {{(BG_COLOR string)}} : Background color name (e.g., "white", "black") ; {{(EMULATE_COLOR boolean)}} : Whether to emulate color on monochrome devices ; {{(MAX_LINE_LENGTH integer)}} : Maximum line segment length for path approximation ; {{(INTERLACE boolean)}} : Whether to use interlaced format (GIF, PNG) ; {{(TRANSPARENT_COLOR string)}} : Color to treat as transparent (GIF, PNG) '''Plotter-Specific Parameters:''' ; {{(CGM_ENCODING string)}} : CGM encoding type ("clear_text" or "binary") ; {{(CGM_MAX_VERSION string)}} : Maximum CGM version (e.g., "1", "2", "3", "4") ; {{(GIF_ANIMATION boolean)}} : Whether to produce animated GIF ; {{(GIF_DELAY integer)}} : Frame delay in hundredths of a second for animated GIFs ; {{(GIF_ITERATIONS integer)}} : Number of times to loop animation (0 = infinite) ; {{(HPGL_ASSIGN_COLORS boolean)}} : Whether to assign pen colors automatically ; {{(HPGL_OPAQUE_MODE boolean)}} : Whether to use opaque drawing mode ; {{(HPGL_PENS string)}} : Number of pens to use ; {{(HPGL_ROTATE string)}} : Rotation angle for HPGL output ; {{(HPGL_VERSION string)}} : HPGL version ("1", "1.5", or "2") ; {{(META_PORTABLE boolean)}} : Whether to use portable metafile format ; {{(PCL_ASSIGN_COLORS boolean)}} : Whether to assign colors automatically ; {{(PCL_BEZIERS boolean)}} : Whether to use native Bezier curve support ; {{(PNM_PORTABLE boolean)}} : Whether to use ASCII (portable) PNM format ; {{(TERM string)}} : Terminal type for display ; {{(USE_DOUBLE_BUFFERING boolean)}} : Whether to use double buffering (X plotter) ; {{(VANISH_ON_DELETE boolean)}} : Whether window vanishes when plotter deleted (X) ; {{(X_AUTO_FLUSH boolean)}} : Whether to flush X display automatically <procedure>(plotter-parameter? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a plotter-parameter value, {{#f}} otherwise. ==== Text Justification <record>h-justify</record> Horizontal text justification. Constructors: ; {{(Left)}} : Left-aligned text ; {{(HCenter)}} : Horizontally centered text ; {{(Right)}} : Right-aligned text <procedure>(h-justify? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a horizontal justification value. <record>v-justify</record> Vertical text justification. Constructors: ; {{(Bottom)}} : Align to bottom of bounding box ; {{(Baseline)}} : Align to text baseline ; {{(VCenter)}} : Vertically centered ; {{(Cap-line)}} : Align to capital letter height ; {{(Top)}} : Align to top of bounding box <procedure>(v-justify? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a vertical justification value. ==== Line Styles <record>linetype</record> Line drawing styles. The following constructors are exported directly as values: ; {{Solid}} : Solid line ; {{Dotted}} : Dotted line ; {{Dotdashed}} : Alternating dots and dashes ; {{Shortdashed}} : Short dashes ; {{Longdashed}} : Long dashes Additional line types (not exported but available via the linetype datatype): ; {{Dotdotdashed}} : Two dots followed by a dash ; {{Dotdotdotdashed}} : Three dots followed by a dash ; {{Disconnected}} : Disconnected line segments ==== Marker Styles <record>marker</record> Point marker styles for plotting discrete points. Constructors: ; {{No-marker}} : No marker drawn ; {{Dot}} : Small dot ; {{Plus}} : Plus sign (+) ; {{Asterisk}} : Asterisk (*) ; {{Circle}} : Circle outline ; {{Cross}} : X-shaped cross ; {{Square}} : Square outline ; {{Triangle}} : Upward-pointing triangle ; {{Diamond}} : Diamond shape ; {{Star}} : Five-pointed star ; {{Inv-triangle}} : Downward-pointing triangle ; {{Starburst}} : Multi-pointed starburst <procedure>(marker? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a marker value. ==== Line Cap Styles <record>capmod</record> Line endpoint cap styles. Constructors: ; {{Butt}} : Square butt caps (default) ; {{CRound}} : Rounded caps ; {{Projecting}} : Projecting square caps ; {{Triangular}} : Triangular caps <procedure>(capmod? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a cap mode value. ==== Fill Modes <record>fillmod</record> Polygon fill rule modes. Constructors: ; {{Alternate}} : Alternate winding rule ; {{Winding}} : Non-zero winding rule <procedure>(fillmod? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a fill mode value. ==== Join Styles <record>joinmod</record> Line segment join styles. Constructors: ; {{Miter}} : Mitered joins (default) ; {{JRound}} : Rounded joins ; {{Bevel}} : Beveled joins <procedure>(joinmod? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a join mode value. ==== Drawing Direction <record>direction</record> Arc and ellipse drawing direction. Constructors: ; {{Clockwise}} : Draw in clockwise direction ; {{Counterclockwise}} : Draw in counterclockwise direction <procedure>(direction? obj) → boolean</procedure> Returns {{#t}} if {{obj}} is a direction value. === Parameter Management <procedure>(params-new) → plotter-params</procedure> Creates a new plotter parameter structure. This structure must be passed to {{make-plotter}} and should be deleted with {{params-delete}} after the plotter is created. <procedure>(params-delete params) → void</procedure> Deletes a plotter parameter structure and frees associated resources. <procedure>(params-copy params) → plotter-params</procedure> Creates a copy of an existing plotter parameter structure. <procedure>(param-set params parameter) → void</procedure> Sets a parameter in a plotter parameter structure. The {{parameter}} argument must be a {{plotter-parameter}} value created with one of the constructors described above. Example: <enscript highlight="scheme"> (param-set params (PAGESIZE "A4")) (param-set params (INTERLACE #t)) </enscript> <procedure>(param-unset params parameter) → void</procedure> Unsets (removes) a parameter from a plotter parameter structure. === Creating and Deleting Plotters <procedure>(make-plotter type out params #!key err) → plotter</procedure> Creates and initializes a new plotter. ; {{type}} : A {{plotter-type}} value specifying the output format ; {{out}} : Output port for plotter graphics data ; {{params}} : List of {{plotter-parameter}} values for configuration ; {{err}} : Optional error output port (keyword argument) Returns a plotter object. The parameter list is processed internally, so you don't need to manage the parameter structure manually. Example: <enscript highlight="scheme"> (define plotter (make-plotter (PNG) (open-output-file "output.png") (list (PAGESIZE "A4") (INTERLACE #t) (BG_COLOR "white")))) </enscript> <procedure>(delete-plotter plotter) → void</procedure> Deletes a plotter and frees all associated resources. The plotter should not be used after deletion. === Control Functions <procedure>(openpl plotter) → void</procedure> Opens a plotter for drawing. This must be called before any drawing operations. <procedure>(closepl plotter) → void</procedure> Closes a plotter and finalizes output. After closing, {{openpl}} can be called again to start a new page or frame. <procedure>(erase plotter) → void</procedure> Erases the current drawing surface, filling it with the background color. <procedure>(space plotter x0 y0 x1 y1) → void</procedure> Sets the coordinate system using integer coordinates. The rectangle from {{(x0, y0)}} to {{(x1, y1)}} in user coordinates is mapped to the plotter's drawable region. <procedure>(fspace plotter x0 y0 x1 y1) → void</procedure> Sets the coordinate system using floating-point coordinates. This is the floating-point version of {{space}}. <procedure>(space2 plotter x0 y0 x1 y1 x2 y2) → void</procedure> Sets up a coordinate system with an arbitrary affine transformation using integer coordinates. Maps {{(x0, y0)}} to the lower-left and {{(x1, y1)}} to the lower-right of the drawable region, with {{(x2, y2)}} specifying the vertical extent. <procedure>(fspace2 plotter x0 y0 x1 y1 x2 y2) → void</procedure> Floating-point version of {{space2}}. <procedure>(bgcolorname plotter color-name) → void</procedure> Sets the background color by name (e.g., "white", "black", "red"). Takes effect on the next {{erase}} operation. <procedure>(havecap plotter capability) → boolean</procedure> Tests whether the plotter has a specific capability. Returns {{#t}} if the capability is supported, {{#f}} otherwise. <procedure>(flushpl plotter) → void</procedure> Flushes drawing output to the output stream. This is primarily useful for X Window and interactive plotters. === Object Drawing Functions ==== Lines and Paths <procedure>(move plotter x y) → void</procedure> Moves the graphics cursor to position {{(x, y)}} using integer coordinates without drawing. <procedure>(fmove plotter x y) → void</procedure> Moves the graphics cursor using floating-point coordinates. <procedure>(moverel plotter dx dy) → void</procedure> Moves the graphics cursor relative to current position using integer offsets. <procedure>(fmoverel plotter dx dy) → void</procedure> Moves the graphics cursor relative to current position using floating-point offsets. <procedure>(cont plotter x y) → void</procedure> Continues the current path by drawing a line segment to {{(x, y)}} using integer coordinates. <procedure>(fcont plotter x y) → void</procedure> Continues the current path using floating-point coordinates. <procedure>(contrel plotter dx dy) → void</procedure> Continues the current path with a relative line segment using integer offsets. <procedure>(fcontrel plotter dx dy) → void</procedure> Continues the current path with a relative line segment using floating-point offsets. <procedure>(line plotter x0 y0 x1 y1) → void</procedure> Draws a line segment from {{(x0, y0)}} to {{(x1, y1)}} using integer coordinates. <procedure>(fline plotter x0 y0 x1 y1) → void</procedure> Draws a line segment using floating-point coordinates. <procedure>(linerel plotter dx0 dy0 dx1 dy1) → void</procedure> Draws a line segment using relative integer coordinates from current position. <procedure>(flinerel plotter dx0 dy0 dx1 dy1) → void</procedure> Draws a line segment using relative floating-point coordinates. <procedure>(endpath plotter) → void</procedure> Ends the current path, drawing and/or filling it according to current attributes. <procedure>(endsubpath plotter) → void</procedure> Ends the current subpath within a compound path. <procedure>(closepath plotter) → void</procedure> Closes the current path by drawing a line segment back to the starting point. ==== Points <procedure>(point plotter x y) → void</procedure> Draws a point or marker at {{(x, y)}} using integer coordinates. <procedure>(fpoint plotter x y) → void</procedure> Draws a point or marker using floating-point coordinates. <procedure>(pointrel plotter dx dy) → void</procedure> Draws a point or marker at a relative position using integer offsets. <procedure>(fpointrel plotter dx dy) → void</procedure> Draws a point or marker at a relative position using floating-point offsets. <procedure>(marker plotter x y type size) → void</procedure> Draws a marker of specified type and size at {{(x, y)}} using integer coordinates. The {{type}} should be a {{marker}} value. <procedure>(fmarker plotter x y type size) → void</procedure> Draws a marker using floating-point coordinates. <procedure>(markerrel plotter dx dy type size) → void</procedure> Draws a marker at a relative position using integer offsets. <procedure>(fmarkerrel plotter dx dy type size) → void</procedure> Draws a marker at a relative position using floating-point offsets. ==== Rectangles <procedure>(box plotter x0 y0 x1 y1) → void</procedure> Draws a rectangle from {{(x0, y0)}} to {{(x1, y1)}} using integer coordinates. The rectangle is drawn and/or filled according to current pen and fill attributes. <procedure>(fbox plotter x0 y0 x1 y1) → void</procedure> Draws a rectangle using floating-point coordinates. <procedure>(boxrel plotter dx0 dy0 dx1 dy1) → void</procedure> Draws a rectangle using relative integer coordinates from the current position. <procedure>(fboxrel plotter dx0 dy0 dx1 dy1) → void</procedure> Draws a rectangle using relative floating-point coordinates. ==== Circles <procedure>(circle plotter x y radius) → void</procedure> Draws a circle centered at {{(x, y)}} with the specified radius using integer coordinates. <procedure>(fcircle plotter x y radius) → void</procedure> Draws a circle using floating-point coordinates. <procedure>(circlerel plotter dx dy radius) → void</procedure> Draws a circle at a position relative to the current point using integer offsets. <procedure>(fcirclerel plotter dx dy radius) → void</procedure> Draws a circle at a relative position using floating-point offsets. ==== Ellipses <procedure>(ellipse plotter x y rx ry angle) → void</procedure> Draws an ellipse centered at {{(x, y)}} with semi-axes {{rx}} and {{ry}}, rotated by {{angle}} degrees, using integer coordinates. <procedure>(fellipse plotter x y rx ry angle) → void</procedure> Draws an ellipse using floating-point coordinates. <procedure>(ellipserel plotter dx dy rx ry angle) → void</procedure> Draws an ellipse at a relative position using integer coordinates. <procedure>(fellipserel plotter dx dy rx ry angle) → void</procedure> Draws an ellipse at a relative position using floating-point coordinates. ==== Arcs <procedure>(arc plotter xc yc x0 y0 x1 y1) → void</procedure> Draws a circular arc from point {{(x0, y0)}} to {{(x1, y1)}}, with center at {{(xc, yc)}}, using integer coordinates. <procedure>(farc plotter xc yc x0 y0 x1 y1) → void</procedure> Draws a circular arc using floating-point coordinates. <procedure>(arcrel plotter dxc dyc dx0 dy0 dx1 dy1) → void</procedure> Draws a circular arc using relative integer coordinates. <procedure>(farcrel plotter dxc dyc dx0 dy0 dx1 dy1) → void</procedure> Draws a circular arc using relative floating-point coordinates. <procedure>(ellarc plotter xc yc x0 y0 x1 y1) → void</procedure> Draws an elliptic arc using integer coordinates. The arc is part of the ellipse that would pass through all three specified points. <procedure>(fellarc plotter xc yc x0 y0 x1 y1) → void</procedure> Draws an elliptic arc using floating-point coordinates. <procedure>(ellarcrel plotter dxc dyc dx0 dy0 dx1 dy1) → void</procedure> Draws an elliptic arc using relative integer coordinates. <procedure>(fellarcrel plotter dxc dyc dx0 dy0 dx1 dy1) → void</procedure> Draws an elliptic arc using relative floating-point coordinates. ==== Bezier Curves <procedure>(bezier2 plotter x0 y0 x1 y1 x2 y2) → void</procedure> Draws a quadratic Bezier curve with control points {{(x0, y0)}}, {{(x1, y1)}}, and {{(x2, y2)}} using integer coordinates. <procedure>(fbezier2 plotter x0 y0 x1 y1 x2 y2) → void</procedure> Draws a quadratic Bezier curve using floating-point coordinates. <procedure>(bezier2rel plotter dx0 dy0 dx1 dy1 dx2 dy2) → void</procedure> Draws a quadratic Bezier curve using relative integer coordinates. <procedure>(fbezier2rel plotter dx0 dy0 dx1 dy1 dx2 dy2) → void</procedure> Draws a quadratic Bezier curve using relative floating-point coordinates. <procedure>(bezier3 plotter x0 y0 x1 y1 x2 y2 x3 y3) → void</procedure> Draws a cubic Bezier curve with control points {{(x0, y0)}}, {{(x1, y1)}}, {{(x2, y2)}}, and {{(x3, y3)}} using integer coordinates. <procedure>(fbezier3 plotter x0 y0 x1 y1 x2 y2 x3 y3) → void</procedure> Draws a cubic Bezier curve using floating-point coordinates. <procedure>(bezier3rel plotter dx0 dy0 dx1 dy1 dx2 dy2 dx3 dy3) → void</procedure> Draws a cubic Bezier curve using relative integer coordinates. <procedure>(fbezier3rel plotter dx0 dy0 dx1 dy1 dx2 dy2 dx3 dy3) → void</procedure> Draws a cubic Bezier curve using relative floating-point coordinates. ==== Text Labels <procedure>(label plotter text) → void</procedure> Draws a text label at the current position. The text is positioned according to the current text justification settings. <procedure>(alabel plotter h-justify v-justify text) → void</procedure> Draws a text label with explicit horizontal and vertical justification. {{h-justify}} should be an {{h-justify}} value and {{v-justify}} should be a {{v-justify}} value. Example: <enscript highlight="scheme"> (alabel plotter (HCenter) (Baseline) "Centered Text") </enscript> === Attribute-Setting Functions ==== Colors <procedure>(color plotter red green blue) → void</procedure> Sets both pen and fill color using RGB values (0-65535 range). This is equivalent to calling both {{pencolor}} and {{fillcolor}}. <procedure>(pencolor plotter red green blue) → void</procedure> Sets the pen (drawing) color using RGB values. <procedure>(fillcolor plotter red green blue) → void</procedure> Sets the fill color using RGB values. <procedure>(bgcolor plotter red green blue) → void</procedure> Sets the background color using RGB values. Takes effect on next {{erase}} operation. <procedure>(colorname plotter color-name) → void</procedure> Sets both pen and fill color by name (e.g., "red", "blue", "#FF0000"). <procedure>(pencolorname plotter color-name) → void</procedure> Sets the pen color by name. <procedure>(fillcolorname plotter color-name) → void</procedure> Sets the fill color by name. ==== Line Attributes <procedure>(linewidth plotter width) → void</procedure> Sets the line width in user coordinates using an integer value. <procedure>(flinewidth plotter width) → void</procedure> Sets the line width in user coordinates using a floating-point value. <procedure>(linemod plotter line-type) → void</procedure> Sets the line style. {{line-type}} should be one of the exported line type values: {{Solid}}, {{Dotted}}, {{Dotdashed}}, {{Shortdashed}}, or {{Longdashed}}. Example: <enscript highlight="scheme"> (linemod plotter Dotted) </enscript> <procedure>(linedash plotter dashes offset) → void</procedure> Sets a custom dash pattern. {{dashes}} is a list of integers specifying dash and gap lengths in user coordinates. {{offset}} is an integer offset into the pattern. Example: <enscript highlight="scheme"> (linedash plotter '(10 5 5 5) 0) ; long dash, gap, short dash, gap </enscript> <procedure>(flinedash plotter dashes offset) → void</procedure> Sets a custom dash pattern using floating-point values. <procedure>(capmod plotter cap-style) → void</procedure> Sets the line cap style. {{cap-style}} should be a {{capmod}} value. <procedure>(joinmod plotter join-style) → void</procedure> Sets the line join style. {{join-style}} should be a {{joinmod}} value. <procedure>(fmiterlimit plotter limit) → void</procedure> Sets the miter limit for mitered line joins. The limit is the maximum ratio of miter length to line width before the join is beveled instead. ==== Fill Attributes <procedure>(filltype plotter fill-fraction) → void</procedure> Sets the fill level. {{fill-fraction}} is an integer from 0 (no fill) to 65535 (solid fill), controlling the density of the fill pattern. <procedure>(fillmod plotter fill-mode) → void</procedure> Sets the fill rule. {{fill-mode}} should be a {{fillmod}} value. ==== Text Attributes <procedure>(fontname plotter font-name) → void</procedure> Sets the current font by name (e.g., "Helvetica", "Times-Roman"). <procedure>(fontsize plotter size) → void</procedure> Sets the font size in user coordinates using an integer value. <procedure>(ffontsize plotter size) → void</procedure> Sets the font size using a floating-point value. <procedure>(textangle plotter angle) → void</procedure> Sets the text rotation angle in degrees using an integer value. <procedure>(ftextangle plotter angle) → void</procedure> Sets the text rotation angle using a floating-point value. <procedure>(labelwidth plotter text) → integer</procedure> Returns the width of a text label in user coordinates as an integer. <procedure>(flabelwidth plotter text) → float</procedure> Returns the width of a text label in user coordinates as a floating-point value. ==== Drawing Modes <procedure>(pentype plotter pen-type) → void</procedure> Sets the pen type (0 = no drawing, 1 = normal drawing). <procedure>(orientation plotter direction) → void</procedure> Sets the path orientation. {{direction}} should be a {{direction}} value. === State Management <procedure>(savestate plotter) → void</procedure> Saves the current graphics state (colors, line styles, fonts, etc.) onto an internal stack. <procedure>(restorestate plotter) → void</procedure> Restores the most recently saved graphics state from the internal stack. === Coordinate Transformation Functions <procedure>(fsetmatrix plotter m0 m1 m2 m3 m4 m5) → void</procedure> Sets the transformation matrix directly. The matrix maps user coordinates {{(x, y)}} to device coordinates using: <enscript> x' = m0*x + m2*y + m4 y' = m1*x + m3*y + m5 </enscript> <procedure>(fconcat plotter m0 m1 m2 m3 m4 m5) → void</procedure> Concatenates (multiplies) the current transformation matrix with the specified matrix. <procedure>(frotate plotter angle) → void</procedure> Rotates the coordinate system by {{angle}} degrees around the origin. <procedure>(fscale plotter sx sy) → void</procedure> Scales the coordinate system by factors {{sx}} horizontally and {{sy}} vertically. <procedure>(ftranslate plotter dx dy) → void</procedure> Translates the coordinate system by {{(dx, dy)}}. == Examples === Basic Example: C Curve <enscript highlight="scheme"> (import plot) (define (ccurve plotter maxorder dx dy order) (if (>= order maxorder) (fcontrel plotter dx dy) (begin (ccurve plotter maxorder (* 0.5 (- dx dy)) (* 0.5 (+ dx dy)) (+ order 1)) (ccurve plotter maxorder (* 0.5 (+ dy dx)) (* 0.5 (- dy dx)) (+ order 1))))) (define (simple-test plotter max-order) (openpl plotter) (fspace plotter 0. 0. 1000. 1000.) (flinewidth plotter 0.25) (pencolorname plotter "blue") (erase plotter) (fmove plotter 600. 300.) (ccurve plotter max-order 0. 400. 0) (closepl plotter)) (define (main) (print "libplot version: " (libplot-version)) (let ((plotter (make-plotter (PNG) (open-output-file "testplot.png") (list (PAGESIZE "A4") (INTERLACE #t) (X_AUTO_FLUSH #f) (META_PORTABLE #t))))) (simple-test plotter 5) (delete-plotter plotter))) (main) </enscript> === Multiple Shapes Example <enscript highlight="scheme"> (import plot) (define (draw-shapes plotter) (openpl plotter) (fspace plotter 0.0 0.0 400.0 400.0) (erase plotter) ; Red filled circle (pencolorname plotter "red") (fillcolorname plotter "pink") (filltype plotter 65535) (fcircle plotter 100.0 100.0 40.0) ; Blue dashed rectangle (pencolorname plotter "blue") (filltype plotter 0) (linemod plotter Dashed) (flinewidth plotter 2.0) (fbox plotter 200.0 50.0 300.0 150.0) ; Green triangle using path (pencolorname plotter "green") (fillcolorname plotter "lightgreen") (filltype plotter 32767) (linemod plotter Solid) (fmove plotter 150.0 250.0) (fcont plotter 250.0 250.0) (fcont plotter 200.0 350.0) (closepath plotter) (endpath plotter) ; Text label (pencolorname plotter "black") (fontname plotter "Helvetica-Bold") (ffontsize plotter 16.0) (alabel plotter (HCenter) (VCenter) "Shapes Demo") (closepl plotter)) (define plotter (make-plotter (SVG) (open-output-file "shapes.svg") (list (PAGESIZE "letter") (BG_COLOR "white")))) (draw-shapes plotter) (delete-plotter plotter) </enscript> === Animated GIF Example <enscript highlight="scheme"> (import plot) (define (draw-frame plotter angle) (openpl plotter) (fspace plotter -150.0 -150.0 150.0 150.0) (erase plotter) (pencolorname plotter "blue") (flinewidth plotter 3.0) ; Rotating line (let ((x (* 100.0 (cos angle))) (y (* 100.0 (sin angle)))) (fline plotter 0.0 0.0 x y)) (closepl plotter)) (define (animate frames) (let ((plotter (make-plotter (GIF) (open-output-file "animation.gif") (list (BITMAPSIZE "300x300") (BG_COLOR "white") (GIF_ANIMATION #t) (GIF_DELAY 5) (GIF_ITERATIONS 0))))) (do ((i 0 (+ i 1))) ((>= i frames)) (draw-frame plotter (* 2.0 3.14159 (/ i frames)))) (delete-plotter plotter))) (animate 36) ; 36 frames for smooth rotation </enscript> == Notes * Integer coordinate functions work with fixnums, while floating-point functions (prefixed with {{f}}) work with flonums. * Colors can be specified either by name (using X11 color names) or by RGB values in the range 0-65535. * The coordinate system must be set using {{space}} or {{fspace}} before drawing operations. * Plotters should be properly closed with {{closepl}} and deleted with {{delete-plotter}} to ensure output is finalized. * For animated GIFs, each call to {{openpl}}/{{closepl}} creates a new frame. * The fill fraction for {{filltype}} ranges from 0 (transparent) to 65535 (opaque/solid). == About this egg === Author [[/users/ivan-raikov|Ivan Raikov]] === Version history ; 2.1-2.2 : Ported to CHICKEN 5 ; 1.1 : Added matchable and datatype as dependencies (thanks to Mario Domenech Goulart) ; 1.0 : Initial release === License Copyright 2011-2026 Ivan Raikov. Based on the Ocamlplot library by Olivier Andrieu. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 7 by 7?