Package: cairo
Macro cairo:with-script-surface
Lambda Listcairo:with-script-surface ((surface path content width height) &body body) SyntaxArgumentsDetails The cairo:with-script-surface macro allocates a new cairo:surface-t instance for a newly created cairo:device-t instance of :script type and executes the
body that uses the Cairo script surface.
After execution of the body the allocated memory for the Cairo surface and the Cairo device is released. This macro calls the cairo:script-create function to create the device and the cairo:script-surface-create
function to create the surface. Examples;; Draw a rectangle on a Cairo context (defun draw-stroke (context width height) (cairo:save context) ;; Clear surface (cairo:set-source-rgb context 1.0 1.0 1.0) (cairo:paint context) ;; Example is in 1.0 x 1.0 coordinate space (cairo:scale context width height) ;; Drawing code goes here (setf (cairo:line-width context) 0.1) (cairo:set-source-rgb context 1.0 0.0 0.0) (cairo:rectangle context 0.25 0.25 0.5 0.5) (cairo:stroke context) (cairo:restore context))This is the output of this example. %!CairoScript << /content //COLOR /width 200 /height 200 >> surface context 1 g set-source paint n 50 50 100 100 rectangle 1 0 0 rgb set-source 200 200 scale 0.1 set-line-width stroke+ show-page pop | See also |
2025-1-29