;; ;; Chicken interface to the libplot API. ;; ;; Copyright 2011 Ivan Raikov. ;; ;; Based on the Ocamlplot library by Olivier Andrieu. ;; ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation, either version 3 of the ;; License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; A full copy of the GPL license can be found at ;; . ;; (define stub_pl_linedash_r (foreign-lambda* void ((ptr_plPlotter plotter) (value dashes) (unsigned-int offset)) #<symbol (sprintf "pl_~A_r" name))) (stubname (string->symbol (sprintf "stub_pl_~A_r" name))) (fplname (string->symbol (sprintf "pl_f~A_r" name))) (fstubname (string->symbol (sprintf "stub_pl_f~A_r" name))) (relplname (string->symbol (sprintf "pl_~Arel_r" name))) (relstubname (string->symbol (sprintf "stub_pl_~Arel_r" name))) (frelplname (string->symbol (sprintf "pl_f~Arel_r" name))) (frelstubname (string->symbol (sprintf "stub_pl_f~Arel_r" name))) (%begin (r 'begin))) `(,%begin (define-plotter-stub ,stubname ,plname . ,(list-tabulate arity (lambda (x) 'int))) (define-plotter-stub ,fstubname ,fplname . ,(list-tabulate arity (lambda (x) 'double))) (define-plotter-stub ,relstubname ,relplname . ,(list-tabulate arity (lambda (x) 'int))) (define-plotter-stub ,frelstubname ,frelplname . ,(list-tabulate arity (lambda (x) 'double))) ))))) ;; TODO: check signedness (define-shape-plot arc 6) (define-shape-plot bezier2 6) (define-shape-plot bezier3 8) (define-shape-plot box 4) (define-shape-plot circle 3) (define-shape-plot cont 2) (define-shape-plot ellarc 6) (define-shape-plot ellipse 5) (define-shape-plot line 4) (define-shape-plot point 2) (define-shape-plot move 2) (define stub_pl_endpath_r (foreign-lambda void "pl_endpath_r" ptr_plPlotter)) (define stub_pl_endsubpath_r (foreign-lambda void "pl_endsubpath_r" ptr_plPlotter)) (define stub_pl_closepath_r (foreign-lambda void "pl_closepath_r" ptr_plPlotter)) (define stub_pl_label_r (foreign-lambda void "pl_label_r" ptr_plPlotter c-string)) ;; Attribute-setting Functions (define-syntax define-attrset (lambda (x r c) (match-let (((_ name argtype) x)) (let ((plname (string->symbol (sprintf "pl_~A_r" name))) (stubname (string->symbol (sprintf "stub_pl_~A_r" name)))) `(define-plotter-stub ,stubname ,plname ,argtype))))) (define-attrset colorname c-string) (define-attrset fillcolorname c-string) ;; TODO: check sign (define-attrset filltype unsigned-int) (define-attrset fmiterlimit double) ;; TODO: check sign (define-attrset linewidth unsigned-int) (define-attrset flinewidth double) (define-attrset pencolorname c-string) ;; TODO: check sign (define-attrset pentype unsigned-int) (define stub_pl_restorestate_r (foreign-lambda void "pl_restorestate_r" ptr_plPlotter)) (define stub_pl_savestate_r (foreign-lambda void "pl_savestate_r" ptr_plPlotter)) ;; Transformation Functions (define stub_pl_fsetmatrix_r (foreign-lambda long "pl_fsetmatrix_r" ptr_plPlotter double double double double double double)) (define stub_pl_fconcat_r (foreign-lambda long "pl_fconcat_r" ptr_plPlotter double double double double double double)) (define stub_pl_frotate_r (foreign-lambda long "pl_frotate_r" ptr_plPlotter double)) (define stub_pl_fscale_r (foreign-lambda long "pl_fscale_r" ptr_plPlotter double double)) (define stub_pl_ftranslate_r (foreign-lambda long "pl_ftranslate_r" ptr_plPlotter double double))