<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>My code is tested. Copy, paste, run, evaluate (my-draw) at repl. If it doesn't work, report the exact actions you perform to get a failure. </div><div><br></div><div><br></div><div><br></div><br><div><div>On Jan 27, 2015, at 1:08 PM, Alexandr M wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div><div><div>Thanks, <br><br>I copied your example and it seems it doesn't work ..<br></div><br>If I comment the code inside [paint-callback .. it also doesn't draw anything.<br><br></div>In general I need to send 'messages' from 'outside' to the canvas object to visualize numerical experiment performed by separate function. <br><br></div> I can implement experiment itself inside [pain-callback (lambda ... functions ) under definition of canvas, but it looks strange and clumsy.<br></div>Sometimes I need just to run computations, but sometimes I need also to do visualization with animation. <br></div><br>How could I achieve this?<br><br><div><div><div><div><div><div><div><div class="gmail_extra">Best regards,<br>Alex<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 January 2015 at 19:54, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Do you want something like this:<br>
<br>
#lang racket/gui<br>
<span class=""><br>
(define frame (new frame% [label ""] [width 700] [height 500]))<br>
(define canvas<br>
(new canvas%<br>
[parent frame]<br>
</span> [paint-callback<br>
(lambda (c dc)<br>
(send dc draw-line 1 1 100 100))]))<br>
(send frame show #true)<br>
<br>
(define (my-draw)<br>
(send (send canvas get-dc) draw-line 100 100 0 200))<br>
<br>
<br>
-- Matthias<br>
<div><div class="h5"><br>
<br>
<br>
On Jan 27, 2015, at 12:09 PM, Alexandr M wrote:<br>
<br>
> Hello,<br>
><br>
> How can I draw the line (for example) in the canvas object defined as:<br>
><br>
> (define frame (new frame% [label ""] [width 700] [height 500]))<br>
> (define canvas (new canvas% [parent frame]<br>
> ;;;; - call from outside: [paint-callback (lambda (c dc) (send dc draw-line 1 1 10 10) )]<br>
> ))<br>
><br>
> by calling a function like<br>
><br>
> (define (MyDraw canvas-obj) .... (draw-line 1 1 10 10))<br>
><br>
> ?<br>
><br>
> --<br>
> Best regards,<br>
> Alex<br>
</div></div>> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Best regards,<br>Alexander Maslov<br></div>
</div></div></div></div></div></div></div></div></div>
</blockquote></div><br></body></html>