emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* exporting Racket images
@ 2017-10-24  1:43 Lawrence Bottorff
  0 siblings, 0 replies; only message in thread
From: Lawrence Bottorff @ 2017-10-24  1:43 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

[-- Attachment #1: Type: text/plain, Size: 1968 bytes --]

I'm using a nice package from a Racket user called MetaPict
<https://github.com/soegaard/metapict>, however, I don't know how to export
the image produced. Here's some Racket code calling MetaPict:

#+begin_src scheme :session mainsession :exports both
(require racket/draw metapict metapict/graph)

(set-curve-pict-size 300 300)  ; width and height of image
(ahlength  1.0)                ; size of arrow head

(define (f x) (sin x))

(define p
  (with-window (window -12 12 -12 12)             ; xmin, xmax, ymin, ymax
    (draw (draw-arrow (curve (pt -10   0) -- (pt 10  0)))  ; x-axis
          (draw-arrow (curve (pt   0 -10) -- (pt  0 10)))  ; y-axis
          (label-rt  "x" (pt 10.2 0))                      ; label for x
axis
          (label-top "y" (pt 0 10.2))                      ; label for y
axis
          (color "blue" (draw (circle (pt 2 1) 3)))        ; center (2,1)
radius 3
          (color "red"  (draw (graph f -10 10 #:samples 50))))))

(define (save-pict-as-svg p width height filename [exists 'replace])
  (define dc (new svg-dc%
                  [width width]
                  [height height]
                  [output filename]
                  [exists exists]))
  (send dc start-doc "An SVG Test")  ; a message
  (send dc start-page)
  (draw-pict p dc 0 0)
  (send dc end-page)
  (send dc end-doc))

(save-pict-as-svg p 300 300 "images/outtestmetapict1.svg")
#+end_src

No surprise, but orgmode doesn't know that the image output

(save-pict-as-svg p 300 300 "images/outtestmetapict1.svg")

should be the code block's results. And adding #+RESULTS: over a hand-added
[[file:images/outtestmetapict1.svg]] link makes it not display. I'm
guessing this means orgmode does things internally with, say, gnuplot to
make the generated image the results *and *obey the :exports both . . . Any
ideas how I can get this gnuplot-like behavior with Racket MetaPict? I'm
guessing a customization of the underlying babel code is necessary. . . .

LB

[-- Attachment #2: Type: text/html, Size: 2704 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-24  1:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24  1:43 exporting Racket images Lawrence Bottorff

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).