Make small scripts to draw with the drawing editor

Hello, I did some tests with the drawing editor. (see attached screenshot)


I can’t use multiple instructions to work in the same window?
I can’t get the “$for” loop to work directly: maybe that’s not possible?
I am interested in this to try to put graduations there.
It is certainly possible.
I’m not a computer expert but I want to learn. I’ve already managed to make myself a few “TeXmacs” commands that make my life easier.
Thanks for your help.

I have the suspicion that for loops draw and successively delete the graphical objects relative to each of their iterations: in fact I am able to draw only one line at a time using the $for command.

I know how to draw using Scheme commands though, outside of the drawing editor. Please take a look at https://texmacs.gitee.io/notes/docs/scheme-graphics.html

Something like this seems to work:

($graphical
 ($for (t (.. 1 5))
  ($line ($point 0 0) ($point 1 t))
  ))
1 Like

And the $graphical form allows as well multiple instructions, I just verified it.

For example this works:

(begin (define ($star-line x y)
  ($line ($point 0 0) ($point x y)))

($graphical ($for (t (.. 1 5)) ($line ($point 0 0) ($point 1 t)) )
       ($line ($point 2 2) ($point -2 -2))
       ($star-line -3 0)))

The begin form allows to execute all of several forms, which cannot be put inside the $graphical form, like function definitions (just verified).

1 Like

Thank you for your answers which are exactly what I expected.
With a few more commands,
(in the gui-markup.scm file), this allows to play with the drawing editor.

Nice to hear it.

Please note that if

is part of the TeXmacs distribution, it will be overwritten when you install a new TeXmacs version, so you need to save a copy of your commands somewhere else.