Reputation: 21
I would like to create a graphic, some points and lines, possibly with colours, out of lists of numbers. What would be the simplest and efficient solution?
I suppose that a possibility would be to use the library imago but I was not very sucessfull with it until now when trying simple examples from https://quickdocs.org/imago like:
;; Create 400x100 px red RGB image
(imago:make-rgb-image 400 100 (imago:make-color 255 0 0))
Symbol "MAKE-GRAYSCALE-IMAGE" not found in the IMAGO package.
How could this work? Do you have any working example I could take a look at?
Upvotes: 0
Views: 276
Reputation: 11854
I made a library called Vectometry for this, and I find it pretty useful. It's vector-based, not pixel-based, and it only outputs PNG files, so its suitability depends on what kind of output you want.
Here's an example:
* (ql:quickload "vectometry")
...
* (in-package :vectometry)
#<PACKAGE "VECTOMETRY">
* (defun red-box (output-file)
(let ((canvas (box 0 0 400 100)))
(with-box-canvas canvas
(set-fill-color (rgb-color 1.0 0.0 0.0))
(clear-canvas)
(save-png output-file))))
RED-BOX
* (red-box "~/red.png")
#p"/path/to/home/directory/red.png"
It follows a postscript- or pdf-style imaging model, with move-to, line-to, curve-to, perspective transforms, etc., so if you are familiar with those operations, it should not be too tricky to use.
Upvotes: 1
Reputation: 38809
In order to use the new constructors, you have to use a more recent version of the library. You need to git clone
the repository inside ~/quicklisp/local-projects/
, and if you already loaded the system:
(delete-package :imago)
Also it can be useful to clean your cache:
$ find ~/.cache/common-lisp -type d -name "imago"
and delete the content.
Then, if you reload the library, it should be the newer version:
(ql:quickload :imago :verbose t)
Alternatively, you can keep your version and make class instances explictly:
(make-instance 'imago:grayscale-image ...)
The rest should work as described in the documentation and examples.
Upvotes: 0