Interface for generating and handling both realtime and offline Hewlett-Packard Graphics Language (HP-GL) commands, which can sent directly to a pen plotter or previewed as an image via the included visualizer.
The scripts/ directory contains some common entrypoints for generating/working with generating HPGL and a pen plotter.
validate-pen-plotter.jl: Test script to ensure plotter serial port connection is valid, then provides a REPL-type interaction with the external pen plotter. Run each command sequentially in the Julia REPL.explore-hpgl-commands.jl: Test script to explore additional pen plotter commands. Run each command sequentially in the REPL.audio-meter-plot.jl: Demonstrates entrypoint to plotting realtime audio, horizontally across the page. Run each command sequentially in the REPL.polar-audio.jl: Demonstrates entrypoint to plotting realtime audio, as spiraling out from the center of the page. Run each command sequentially in the REPL.
To plot a full pre-generated HPGL file with an external pen plotter, use this external chunker utility.
With Julia installed, start the Julia REPL and add this package to your environment:
using Pkg
Pkg.add("url="https://github.com/hannahilea/HPGL.jl")
using HPGL
The following examples are all demonstrated with the backend destination set to the visualizer, so that it can be demoed by all users. If you have access to a pen plotter or other backend, it can be swapped for all uses of viz below.
To preview an HPGL file with the visualizer, do
using HPGL
viz=set_up_visualization_plotter()
plot_hpgl_file!(viz, "examples/demo.hpgl")
display(viz) # to view
Use debug mode to additionally draw the borders of the plottable area as well as draw the paths of all pen-up movements:
using HPGL
viz = set_up_visualization_plotter(VisualizationConfig(; debug=true))
plot_hpgl_file!(viz, "examples/demo.hpgl")
display(viz) # to view
save_visualization(viz, "demo.png") # save image
save_visualization(viz, "demo.svg") #...or as svg
For additional configuration, see help docs by doing ?plot_hpgl_file! in the REPL.
To preview HPGL commands one at a time, do
using HPGL
# set up basic plotter output figure
viz = set_up_visualization_plotter()
# plot initial input commands
plot_commands!(viz, ["IN", "SP1", "PA 300,300", "PD"])
# plot commands one at a time
plot_command!(viz, "PA 3000,3000")
# plot commands in bulk
cmds = map(x -> "PA $x,$(x^1.1)", 1:10:1_000)
plot_commands!(viz, cmds)
To validate a file, call validate_hpgl_file with the destination type:
using HPGL
destination = set_up_visualization_plotter()
validate_hpgl_file(destination, joinpath(pkgdir(HPGL), "examples/demo.hpgl")) # No output if file is valid
validate_hpgl_file(destination, joinpath(pkgdir(HPGL), "examples/invalid_file.hpgl")) # Shows warnings for unexpected/invalid file contents
Validation not yet set implemented for all destinations.