Index of /code/art/examples

 NameLast modifiedSizeDescription

 Parent Directory   -  
 compile.xqy 2023-02-24 08:49 810  
 compile.xsl 2023-04-20 08:25 1.4K 
 contours.xqy 2023-07-23 07:39 4.7K 
 contours.xsl 2023-07-23 07:39 6.7K 
 delaunay.xqy 2023-04-20 08:25 3.2K 
 delaunay.xsl 2023-04-20 08:25 4.7K 
 dither.xqy 2023-04-20 08:25 849  
 dither.xsl 2023-04-20 08:25 1.7K 
 extract.xqy 2023-02-24 08:49 1.4K 
 extract.xsl 2023-04-20 08:25 2.7K 
 fish.xqy 2023-04-20 08:25 11K 
 fish.xsl 2023-04-20 08:25 12K 
 imagemap.xqy 2023-04-20 08:25 2.6K 
 imagemap.xsl 2023-04-20 08:25 4.3K 
 layout.xqy 2023-04-20 08:25 3.0K 
 layout.xsl 2023-04-20 08:25 5.1K 
 loop.xqy 2023-02-24 08:49 1.5K 
 loop.xsl 2023-04-20 08:25 3.1K 
 render.xqy 2023-04-20 08:25 5.1K 
 render.xsl 2023-04-20 08:25 7.1K 
 runall.sh 2022-12-17 14:47 957  
 sdf.xqy 2023-04-20 08:25 3.7K 
 sdf.xsl 2023-04-20 08:25 6.9K 
 splittree.xqy 2023-02-24 08:49 2.4K 
 splittree.xsl 2023-04-20 08:25 4.6K 
 tactile.xqy 2023-04-20 08:25 8.5K 
 tactile.xsl 2023-04-20 08:25 11K 
 tag.xqy 2023-02-24 08:49 1.0K 
 tag.xsl 2023-04-20 08:25 2.0K 
 tree.xqy 2023-04-20 08:25 3.2K 
 tree.xsl 2023-04-20 08:25 6.2K 
 wfc.xqy 2023-04-20 08:25 6.6K 
 wfc.xsl 2023-04-20 08:25 9.0K 

Examples

You can run these with the makefile: make examples.

Note: examples that depend on the PNG library (i.e. WFC) will not run in Saxon 12.0 unless you add additional JAR files (e.g. JDOM2) to the classpath. The makefile is set up to use $ALT-CLASSPATH here.

Note: examples that depend on writing files will not run in Saxon-JS as the EXPath file module is not available in that context.

Art and geometry

fish.xqy

Draws a simple picture of random fish with a random polynomial spiral over a neutral background.

Output is SVG; save to a file to view.

Demonstrating the use various geometric and artistic components:

More: ../core/api.html, ../geo/api.html, ../components/api.html

fish.xsl

Same as fish.xqy, but using XSLT versions of the API.

render.xqy

Generates SVG from a few simple shapes. The scene consists of a couple of circles, a straight edge, a curved edge, a little text, and a dense adhoc colour fill.

The output is SVG; save to a file to view.

See ../svg/draw.xqy, ../geo/ellipse.xqy, ../geo/edge.xqy, ../types/text.xqy.

More: ../geo/api.html

render.xsl

Same as render.xqy, but using XSLT versions of the API.

tactile.xqy

Constructs a sample isohedral tiling.

Output is SVG; save to a file to view.

Takes command line parameters:

See ../tiling/isohedral-tiling.xqy, ../types/isohedral-tiling.xqy

tactile.xsl

Same as tactile.xqy, but using XSLT versions of the API.

tree.xqy

Draws a simple picture of random tree created with a stochastic L-system.

Output is SVG; save to a file to view.

More: ../core/api.html, ../geo/api.html, ../shapes/api.html

tree.xsl

Same as tree.xqy, but using XSLT versions of the API.

wfc.xqy

Simple adhoc tiling using Wave Function Collapse algorithm (explainer at https://mathling.com/art/20220719_wfc.html).

Output is an SVG file representing the tiling. If the collapse failed, you'll see "pick failed" in the output and a blank canvas.

See ../wfc/adhoc-tiled-model.xqy.

More ../wfc/api.html.

wfc.xsl

Same as wfc.xqy, but using XSLT versions of the API.

Algorithms

delaunay.xqy

Contruct the Delaunay triangulation of a set of random points, or the Voronoi cells (dual of the triangulation).

Output is SVG of the triangulation or cells plus the seed points. Save to a file to view.

The parameter "mode" controls whether to show triangulation or Voronoi cells:

delaunay.xsl

Same as delaunay.xqy, but using XSLT versions of the API.

layout.xqy

Layout a set of randomly connected random points using ARF algorithm.

Output is SVG file with the original graph (silver) and the laid out graph (blue). Save to file to view.

See ../geo/arf.xqy.

More ../geo/api.html.

layout.xsl

Same as layout.xqy, but using XSLT versions of the API.

contours.xqy

Contruct simple contours (unconnected edges) of the rounded union of two random circles.

Output is SVG of the contour edges. Save to a file to view.

contours.xsl

Same as contours.xqy, but using XSLT versions of the API.

splittree.xqy

Computes a fair split tree over a set of points, and then a well-separated pairwise decomposition and spanning edges with two different distance metrics.

Output is adhoc XML showing the splits.

See ../geo/rectangle.xqy, ../geo/splittree.xqy, ../geo/wspd.xqy.

More ../geo/api.html.

splittree.xsl

Same as splittree.xqy, but using XSLT versions of the API.

Entity matching and extraction

compile.xqy

Demonstrates compilation of entity dictionary as JSON from text file.

Output is the compiled JSON entity dictionary suitable for use by entity:extract() or entity:markup().

See ../string/entity.xqy.

More ../string/api.html.

compile.xsl

Same as compile.xqy, but using XSLT versions of the API.

extract.xqy

Constructs an ad hoc entity dictionary of dramatis personae and uses it to extract and count instances of those names in Hamlet.

Output is text of names and their counts.

See ../string/aho.xqy.

More ../string/api.html.

extract.xsl

Same as extract.xqy, but using XSLT versions of the API.

tag.xqy

Applies full entity markup to all matches for all nouns in the compiled noun entity dictionary to the play Hamlet.

See ../string/entity.xqy/

More ../string/api.html.

Images

dither.xqy

Reads an image, dithered, and writes it out again as a P3 file. P3 files are textual raw image files: they can be converted and read by some programs such as ImageMagick, Gimp, or InkScape.

Requires EXPath binary and file functions.

Output is in two files: examples/dither_raw.p3 and examples/dither_dither4.p3, written to $TMPDIR (default is /tmp).

See ../image/dithering.xqy, ../image/ppm.xqy.

More ../image/api.html.

dither.xsl

Same as dither.xqy, but using XSLT versions of the API.

Output is in two files: examples/dither_raw.xsl.p3 and examples/dither_dither4.xsl.p3, written to $TMPDIR (default is /tmp).

imagemap.xqy

Constructs a simple colour map based on Perlin noise and renders it out as a P3, P6, and PAM file. P3 files are textual raw image files. P6 files are binary raw image files. PAM files are binary raw image files with more capabilities. They all can be converted and read by some programs such as ImageMagick, Gimp, or InkScape.

Requires EXPath binary and file functions.

Output is in three files: examples/imagemap.p3, examples/imagemap.p6, and examples/imagemap.pam, written to $TMPDIR (default is /tmp).

See ../image/ppm.xqy, ../noise/perlin.xqy, ../noise/modifiers.xqy, ../noise/noise-map.xqy.

More ../image/api.html.

imagemap.xsl

Same as imagemap.xqy, but using XSLT versions of the API.

Output is in three files: examples/imagemap.xsl.p3, examples/imagemap.xsl.p6, and examples/imagemap.xsl.pam, written to $TMPDIR (default is /tmp).

sdf.xqy

Computes the colouring of a simple 3D scene using SDF functions to construct the colour matrix and output the result as a P6 file. A P6 file is a binary raw image file that can be converted and read by some programs such as ImageMagick, Gimp, or InkScape.

Requires EXPath binary and file functions.

This takes a while: the larger the canvas the longer it takes!

Output is in a file: examples/sdf.p6, written to $TMPDIR (default is /tmp).

See ../sdf/sdf.xqy, ../sdf/sd3.xqy.

sdf.xsl

Same as sdf.xqy, but using XSLT versions of the API.

Output is in a file: examples/sdf.xsl.p6, written to $TMPDIR (default is /tmp).

Randomization Testing

loop.xqy

Tests random selection in a loop. Returns a textual description of what happened.

See ../core/random.xqy.

More ../core/api.html.

loop.xsl

Same as loop.xqy, but using XSLT versions of the API.