Let "Save as Image" center and cut

5 views
Skip to first unread message

Christoph Knabe

unread,
Apr 10, 2015, 8:01:57 AM4/10/15
to kojo...@googlegroups.com
When preparing the slides for my course "Programming I" in media informatics I often have to include some Kojo source code and the image produced by it. There is an action in the context menu of the Drawing Canvas named "Save as Image", which stores the current image as a .png file.

Unfortunately this action is very uncomfortable, if you have to produce many such images. Seems that the action stores an image of the size, which the Drawing Canvas currently has. So if your window is big, your image will occupy much screen area and maybe much disk space without contributing content.
As workaround I reduce the Drawing Canvas step by step before saving. But after each step the image disappears or maybe is centered to (0, 0) instead of depending on the content. So I repeatedly have to re-center the image by moving it by mouse. From other graphics programs I know the possibility to center and reduce the size conserving all content.

Lalit Pant

unread,
Apr 10, 2015, 9:38:02 AM4/10/15
to Christoph Knabe, kojo...@googlegroups.com
Usage of the commands described below might ease your situation. These commands allow you to center the canvas wherever you want, and export the contents of the canvas to an image of a specified size.

zoom(factor, cx, cy) - Zooms in by the given factor, and positions (cx, cy) at the center of the turtle canvas.

exportImageH(filePrefix, h) - Saves the contents of the drawing canvas as an image with the given height, in a file located in the temporary directory on your machine. The name of the file starts with filePrefix. Kojo prints out the full path of the exported image file in the output pane so that you can easily locate the file.

exportImageW(filePrefix, w) - Saves the contents of the drawing canvas as an image with the given width, in a file located in the temporary directory on your machine. The name of the file starts with filePrefix. Kojo prints out the full path of the exported image file in the output pane so that you can easily locate the file.

You can also use your OS tools for screenshots and image cropping!

But feel free to open an enhancement request for this at:
https://bitbucket.org/lalit_pant/kojo/issues?status=new&status=open

- Lalit



--
You received this message because you are subscribed to the Google Groups "kojo-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kojo-user+...@googlegroups.com.
To post to this group, send email to kojo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kojo-user/0fb5e8aa-e9c6-4d1f-a228-be6c1a65bba7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages