emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Lawrence Bottorff <borgauf@gmail.com>
To: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: exporting Racket images
Date: Mon, 23 Oct 2017 21:43:50 -0400	[thread overview]
Message-ID: <CAFAhFSW9iQ8vJ-wmU7rKGfqEQHwRJwebt-7e-mcDDNB8PcQB+g@mail.gmail.com> (raw)

[-- 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 --]

                 reply	other threads:[~2017-10-24  1:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFAhFSW9iQ8vJ-wmU7rKGfqEQHwRJwebt-7e-mcDDNB8PcQB+g@mail.gmail.com \
    --to=borgauf@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).