patch from Alex
svn: r575
This commit is contained in:
parent
fab4b76258
commit
9bfbc7dcb6
|
@ -1,5 +1,5 @@
|
||||||
(require (lib "plot.ss" "plot"))
|
(require (lib "plot.ss" "plot"))
|
||||||
|
|
||||||
(plot
|
(plot
|
||||||
(vector-field (gradient (lambda (x y) (* (sin x) (cos y)))) (samples 25))
|
(vector-field (gradient (lambda (x y) (* (sin x) (cos y)))) (samples 25))
|
||||||
(title "gradient field of F(x,y) = sin(x) * sin(y)"))
|
(title "gradient field of F(x,y) = sin(x) * sin(y)"))
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
(define* pl-setup-page
|
(define* pl-setup-page
|
||||||
(get-ffi-obj "c_plspage" libplplot
|
(get-ffi-obj "c_plspage" libplplot
|
||||||
(_fun (xp : _plint = 0)
|
(_fun (xp : _plflt = 0.0)
|
||||||
(yp : _plint = 0)
|
(yp : _plflt = 0.0)
|
||||||
(xleng : _plint)
|
(xleng : _plint)
|
||||||
(yleng : _plint)
|
(yleng : _plint)
|
||||||
(xoff : _plint = 0)
|
(xoff : _plint = 0)
|
||||||
|
|
|
@ -47,24 +47,25 @@
|
||||||
get-x-max
|
get-x-max
|
||||||
get-y-min
|
get-y-min
|
||||||
get-y-max
|
get-y-max
|
||||||
|
|
||||||
get-x-label
|
get-x-label
|
||||||
get-y-label
|
get-y-label
|
||||||
get-title
|
get-title
|
||||||
start-plot
|
start-plot
|
||||||
finish-plot
|
finish-plot
|
||||||
|
|
||||||
get-renderer
|
get-renderer
|
||||||
|
|
||||||
get-height
|
get-height
|
||||||
get-width)
|
get-width)
|
||||||
|
|
||||||
(init-field
|
(init-field
|
||||||
renderer)
|
renderer)
|
||||||
|
|
||||||
(fields-with-accessors
|
(fields-with-accessors
|
||||||
(height 300)
|
(height 300)
|
||||||
(width 400)
|
(width 400)
|
||||||
|
(out-file #f) ;; if file is not #f, keep the file
|
||||||
(x-min -5)
|
(x-min -5)
|
||||||
(x-max 5)
|
(x-max 5)
|
||||||
(y-min -5)
|
(y-min -5)
|
||||||
|
@ -75,13 +76,12 @@
|
||||||
(device 'png)
|
(device 'png)
|
||||||
(fgcolor '( 0 0 0))
|
(fgcolor '( 0 0 0))
|
||||||
(bgcolor '(255 255 255))
|
(bgcolor '(255 255 255))
|
||||||
(lncolor '(255 0 0 ))
|
(lncolor '(255 0 0 )))
|
||||||
)
|
|
||||||
|
|
||||||
(define bitmap #f)
|
(define bitmap #f)
|
||||||
(define x-size 400)
|
(define x-size 400)
|
||||||
(define y-size 300)
|
(define y-size 300)
|
||||||
|
|
||||||
(inherit
|
(inherit
|
||||||
set-bitmap
|
set-bitmap
|
||||||
load-file)
|
load-file)
|
||||||
|
@ -120,26 +120,28 @@
|
||||||
(let ((index (cond [(assq color colors ) => cadr]
|
(let ((index (cond [(assq color colors ) => cadr]
|
||||||
[else (error (string-append "color \"" color "\" not found"))])))
|
[else (error (string-append "color \"" color "\" not found"))])))
|
||||||
(pl-select-colormap0-index index)))
|
(pl-select-colormap0-index index)))
|
||||||
|
|
||||||
; start the plot
|
; start the plot
|
||||||
; does housekeeping/setup for plplot
|
; does housekeeping/setup for plplot
|
||||||
(define (start-plot)
|
(define (start-plot)
|
||||||
(cond
|
(cond
|
||||||
[(eq? device 'png)
|
[(eq? device 'png)
|
||||||
(set! bitmap (make-temporary-file))
|
(set! bitmap (if out-file
|
||||||
(init-colors)
|
(build-path out-file)
|
||||||
(pl-setup-page width height)
|
(make-temporary-file)))
|
||||||
(pl-set-device "png")
|
(init-colors)
|
||||||
(pl-set-output-file (path->string bitmap))
|
(pl-setup-page width height)
|
||||||
(pl-init-plot)]
|
(pl-set-device "png")
|
||||||
; [(eq? device 'mem)
|
(pl-set-output-file (path->string bitmap))
|
||||||
; (init-colors)
|
(pl-init-plot)]
|
||||||
; (set! bitmap (make-u8vector (* x-size y-size 4) 255))
|
; [(eq? device 'mem)
|
||||||
; (pl-setup-memory x-size y-size bitmap)
|
; (init-colors)
|
||||||
; (pl-set-device "mem")
|
; (set! bitmap (make-u8vector (* x-size y-size 4) 255))
|
||||||
; (pl-init-plot)]
|
; (pl-setup-memory x-size y-size bitmap)
|
||||||
[else
|
; (pl-set-device "mem")
|
||||||
(error "Incorrect device specified")]))
|
; (pl-init-plot)]
|
||||||
|
[else
|
||||||
|
(error "Incorrect device specified")]))
|
||||||
|
|
||||||
; finish the plot.. loads the file
|
; finish the plot.. loads the file
|
||||||
(define (finish-plot)
|
(define (finish-plot)
|
||||||
|
@ -147,7 +149,7 @@
|
||||||
[(eq? device 'png)
|
[(eq? device 'png)
|
||||||
(pl-finish-plot)
|
(pl-finish-plot)
|
||||||
(load-file bitmap)
|
(load-file bitmap)
|
||||||
(delete-file bitmap)]
|
(or out-file (delete-file bitmap))]
|
||||||
; [(eq? device 'mem)
|
; [(eq? device 'mem)
|
||||||
; (pl-finish-plot)
|
; (pl-finish-plot)
|
||||||
; (set-bitmap (bits->bitmap-dc% bitmap))]
|
; (set-bitmap (bits->bitmap-dc% bitmap))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user