Skip to content

Instantly share code, notes, and snippets.

@lamberta
Created October 24, 2009 20:42
Show Gist options
  • Save lamberta/217730 to your computer and use it in GitHub Desktop.
Save lamberta/217730 to your computer and use it in GitHub Desktop.
vecto example - draw text, circle, line
;;vecto example
;;draw text, circle, and some lines
(require :asdf)
(asdf:load-system :vecto)
(defparameter *font* "/home/billy/.fonts/Consola.ttf")
(defun draw-it (file)
(vecto:with-canvas (:width 200 :height 200)
(let ((font (vecto:get-font *font*))
(step (/ pi 7)))
(vecto:with-graphics-state
(vecto:set-rgb-fill 1 1 0) ;set bgcolor to yellow
(vecto:clear-canvas))
;;text
(vecto:set-font font 40)
(vecto:translate 100 100)
(vecto:draw-centered-string 0 0 "hello")
;;circle
(vecto:set-rgb-stroke 1 0 0)
(vecto:set-line-width 2)
(vecto:centered-circle-path 0 0 90)
(vecto:stroke)
;;ticks
(vecto:set-rgba-stroke 0 0 1.0 0.5)
(vecto:set-line-width 4)
(dotimes (i 14)
(vecto:with-graphics-state
(vecto:rotate (* i step))
(vecto:move-to 80 0)
(vecto:line-to 90 0)
(vecto:stroke)))
(vecto:save-png file))))
(draw-it "output.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment