New vecto

Jun. 30th, 2008 | 04:36 pm

I pushed out Vecto 1.3.1. New in this version:

  • stroke-to-paths will convert stroke outlines of the current path to a new set of paths you can fill
  • string-paths will add paths for a string in the current font, instead of painting the text
  • set-gradient-fill will let you fill paths with a simple axial gradient. It's not much, but it's a start...

Many thanks to Ben Deane for providing a functional fill patch that made adding gradients much easier, and for suggesting the text-to-paths functionality. Thanks also to Jakub Higersberger for showing me how easy gradients could be. (I wound up using a very simple formula straight from the Adobe PDF Reference.)

This uses a simple white-to-transparent gradient:

Here's some code that uses all three new features:

(defun text-paths (file)
  (with-canvas (:width 400 :height 100)
    (set-font (get-font "/tmp/font.ttf") 70)
    (centered-string-paths 200 15 "Hello, world!")
    (set-line-join :round)
    (set-line-cap :round)
    (set-line-width 3)
    (set-dash-pattern #(0 5) 0)
    (stroke-to-paths)
    (set-gradient-fill 0 0   1 0 0 0.5
                       0 100 1 1 1 1)
    (fill-path)
    (save-png file)))

I fell short of exporting and documenting the functional fill option that enabled gradients, because I've run out of time. Maybe next release!

Tags: ,

Link | Leave a comment {3} | Add to Memories | Tell a Friend

New Vecto

Apr. 8th, 2008 | 04:11 pm

Vecto 1.2.1 is out. This release adds support for circle arc paths, adapted from Ben Deane's curve library.

I have a few more pending features that should become part of Vecto soon, including tilty ellipses, arbitrary fill functions (both courtesy of Ben, again), and simple gradient support courtesy of Ramarren. They'll make it even easier to draw really pretty things with Vecto.

Enjoy!

Tags: ,

Link | Leave a comment {4} | Add to Memories | Tell a Friend

Cool vecto use

Nov. 21st, 2007 | 04:43 pm

Drawing the Apollonian Gasket with Common Lisp and Vecto

Link | Leave a comment | Add to Memories | Tell a Friend

welcome to planet vecto

Oct. 1st, 2007 | 04:17 pm

Vecto 1.0.2 is out. It depends on the new 1.0.1 release of Salza-PNG to support writing the backing PNG out to a stream instead of to a file. My favorite new and exciting thing, though, is the addition of a clipping path.

There have been some little documentation & code fixes too. (This will be the last release announcement that makes it to Planet Lisp, until there's something really big and new and exciting to announce.)

Tags: ,

Link | Leave a comment {1} | Add to Memories | Tell a Friend

Smiles with Vecto 1.0.1, plus some Hunchentoot

Sep. 29th, 2007 | 10:11 pm

Dimitry Gashinsky made my day by sending me a bugfix patch to Vecto and a link to this blog entry. I've released Vecto 1.0.1 with his patch applied, along with some minor documentation updates.

In unrelated news, Robert Synnott wrote a nice guide to getting started with Hunchentoot.

Tags: ,

Link | Leave a comment | Add to Memories | Tell a Friend

Vecto 1.0

Sep. 28th, 2007 | 04:11 pm

Vecto 1.0 is available for download, and should be asdf-installable. If you try it out, and something doesn't work, please mail me, ok?

And remember:

:MITER :BEVEL :ROUND
Tags: ,

Link | Leave a comment {2} | Add to Memories | Tell a Friend

MORE LISP TOYS

Sep. 26th, 2007 | 04:50 pm

I got a little sidetracked when creating Vecto and made easystreet, a new wigflip toy. I had been meaning to make something like this for a while, but Vecto made it almost trivial to draw everything.

Link | Leave a comment {5} | Add to Memories | Tell a Friend

Vecto teaser

Sep. 13th, 2007 | 10:46 pm

Here is some demo code from something I'm working on:

(defun random-points (count variation)
  (loop repeat count collect (- variation (random (* variation 2)))))

(defun mo-money (file &key (random-steps 4) (random-variation 10)
                 (width 200)
                 (height 200))
  (let ((points (random-points random-steps random-variation))
        (step (/ width (1+ random-steps))))
    (flet ((graph-path ()
             (move-to 0 0)
             (loop for v in points
                  for y from step by step
                  for x from step by step
                  do (line-to x (+ y v)))
             (line-to width height)))
      (with-canvas (:width width :height height)
        (let ((font (get-font "folion.ttf")))
          (set-rgb-fill 0.9 0.9 0.9)
          (clear-canvas)
          (with-graphics-state
            (translate 10 10)
            (scale 0.8 0.8)
            (set-line-cap :butt)
            (set-line-join :miter)
            (translate 25 25)
            (set-line-width 4)
            ;; Shadow
            (set-rgba-stroke 0.5 0.5 0.5 0.5)
            (graph-path)
            (stroke)
            ;; Graph
            (set-rgb-stroke 0.4 0.5 1.0)
            (translate -1 1)
            (graph-path)
            (stroke))
          ;; Labels
          (set-font font 24)
          (with-graphics-state
            (translate 50 10)
            (set-rgba-fill 0 0 0 0.25)
            (draw-string "$Money")
            (translate -1 1)
            (set-rgb-fill 0.1 0.5 0.3)
            (draw-string "$Money"))
          (with-graphics-state
            (rotate-degrees 90)
            (translate 50 -24)
            (set-rgba-fill 0 0 0 0.25)
            (draw-string "Problems")
            (translate 1 1)
            (set-rgb-fill 0.9 0.3 0.1)
            (draw-string "Problems")))
        (save-png file)))))

Here's the result:

It's basically a PNG-generating cl-pdf-like sugar layer atop cl-vectors, salza-png, and zpb-ttf. Everything's in portable Common Lisp; none of the work is done by external C libraries. I have a bit of work left to do on text support, but it's almost ready for public consumption.

Tags: ,

Link | Leave a comment {7} | Add to Memories | Tell a Friend