Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Racket bindings for the IupPlot control |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
af610253ba86e71ece284a3107d37308 |
User & Date: | murphy 2015-05-01 14:03:03.987 |
Context
2015-05-01
| ||
14:29 | Documented IupPlot binding check-in: c7943a8242 user: murphy tags: trunk | |
14:03 | Racket bindings for the IupPlot control check-in: af610253ba user: murphy tags: trunk | |
13:52 | CHICKEN bindings for the IupPlot control check-in: 7433020851 user: murphy tags: trunk | |
Changes
Added racket/plot.rkt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #lang racket (require ffi/unsafe "base.rkt") (define libiup-plot (case (system-type 'os) [(windows) (ffi-lib "iup_plot")] [else (ffi-lib "libiup_plot")])) ;; plot control (define plot (make-constructor-procedure (get-ffi-obj "IupPlot" libiup-plot (_fun -> [handle : _ihandle])))) ;; Plotting functions (define call-with-plot (letrec ([plot-begin (get-ffi-obj "IupPlotBegin" libiup-plot (_fun [handle : _ihandle] [xdata-string? : _bool] -> _void))] [plot-end (get-ffi-obj "IupPlotEnd" libiup-plot (_fun [handle : _ihandle] -> _void))]) (λ (handle proc #:x-string? [x-string? #f]) (dynamic-wind (λ () (plot-begin handle x-string?)) (λ () (proc handle)) (λ () (plot-end handle)))))) (define plot-add! (letrec ([append/real (get-ffi-obj "IupPlotAdd" libiup-plot (_fun [handle : _ihandle] [x : _double] [y : _double] -> _void))] [append/string (get-ffi-obj "IupPlotAddStr" libiup-plot (_fun [handle : _ihandle] [x : _string/utf-8] [y : _double] -> _void))] [insert/real (get-ffi-obj "IupPlotInsert" libiup-plot (_fun [handle : _ihandle] [index : _int] [sample-index : _int] [x : _double] [y : _double] -> _void))] [insert/string (get-ffi-obj "IupPlotInsertStr" libiup-plot (_fun [handle : _ihandle] [index : _int] [sample-index : _int] [x : _string/utf-8] [y : _double] -> _void))] [current-index (λ (handle) (string->number (attribute handle 'current)))]) (λ (handle x y [sample-index #f] [index #f]) (if (string? x) (if sample-index (insert/string handle (or index (current-index handle)) sample-index x (exact->inexact y)) (append/string handle x (exact->inexact y))) (if sample-index (insert/real handle (or index (current-index handle)) sample-index (exact->inexact x) (exact->inexact y)) (append/real handle (exact->inexact x) (exact->inexact y))))))) (define plot-x/y->pixel-x/y (get-ffi-obj "IupPlotTransform" libiup-plot (_fun (handle x y) :: [handle : _ihandle] [plot-x : _double = (exact->inexact x)] [plot-y : _double = (exact->inexact y)] [pixel-x : (_ptr o _double)] [pixel-y : (_ptr o _double)] -> _void -> (values pixel-x pixel-y)))) (define plot-paint-to (get-ffi-obj "IupPlotPaintTo" libiup-plot (_fun [handle : _ihandle] [canvas : _pointer] -> _void))) ;; Library setup (letrec ([open (get-ffi-obj "IupPlotOpen" libiup-plot (_fun -> _void))]) (open)) (provide plot call-with-plot plot-add! plot-x/y->pixel-x/y plot-paint-to) |