From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Bottorff Subject: exporting Racket images Date: Mon, 23 Oct 2017 21:43:50 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f4030435adb02ec65e055c41121a" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e6oG1-0006c0-Ut for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 21:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e6oG0-0000bZ-N6 for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 21:43:53 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:53380) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e6oG0-0000ab-GB for emacs-orgmode@gnu.org; Mon, 23 Oct 2017 21:43:52 -0400 Received: by mail-oi0-x22d.google.com with SMTP id h6so34289505oia.10 for ; Mon, 23 Oct 2017 18:43:52 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode Mailinglist --f4030435adb02ec65e055c41121a Content-Type: text/plain; charset="UTF-8" I'm using a nice package from a Racket user called 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 --f4030435adb02ec65e055c41121a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm using a nice package from a Racket user called MetaPict, however, I don&= #39;t know how to export the image produced. Here's some Racket code ca= lling MetaPict:

#+begin_src scheme :session mainses= sion :exports both
(require racket/draw metapict metapict/graph)<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
(set-curve-pict-size= 300 300)=C2=A0 ; width and height of image
(ahlength=C2=A0 1.0)= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ; size of arrow hea= d=C2=A0

(define (f x) (sin x))

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

(define (save-pict-as-svg p= width height filename [exists 'replace])
=C2=A0 (define dc (= new svg-dc%
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 [width width]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 [height height]
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [output filename]
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [exists exists]))
=C2=A0 (send dc start-doc "An SVG Test")=C2=A0 ; a messa= ge
=C2=A0 (send dc start-page)
=C2=A0 (draw-pict p dc 0= 0)
=C2=A0 (send dc end-page)
=C2=A0 (send dc end-doc))=
=C2=A0=C2=A0
(save-pict-as-svg p 300 300 "ima= ges/outtestmetapict1.svg")
#+end_src

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

(save-pict-as-svg p 300 300 "images/outtestmetap= ict1.svg")

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

LB
--f4030435adb02ec65e055c41121a--