June 30th, 2008

New vecto

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)
    (set-gradient-fill 0 0   1 0 0 0.5
                       0 100 1 1 1 1)
    (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!