Have you heard of Maple Scripting before? Do you want to extend your Maple Learn documents with your Maple knowledge? Scripting is the process of using Maple to create Maple Learn documents. If you’re already used to Maple, this may be a piece of cake for you, but we wanted to start from the basics for anyone who wants to extend their Maple Learn and Maple knowledge. This process can be used for many different types of documents, from quizzes to intensive 3D visualizations.
So, let’s get started! All Maple Learn document scripting needs the DocumentTools:-Canvas package. The canvas, as you know, is that white space in a Maple Learn document. Therefore, this package is the core content of a scripted document! Always put:
At the top of your code, or put
At the start of your procedures.
Now that we’ve told Maple to use the DocumentTools:-Canvas, we need to create a canvas.
Canvases are created as variables, using the command NewCanvas. Inside NewCanvas, you will add a square-bracket list of all the content you want to see inside. For now, just know that you can add text cells with Text(“YOUR TEXT”) and a math cell with Math(YOUR MATH). On the next line, make sure to put either ShareCanvas(YOUR CANVAS VARIABLE) or ShowCanvas(YOUR CANVAS VARIABLE). ShareCanvas creates a Maple Learn sharelink, while ShowCanvas shows the canvas directly in Maple. Note that ShowCanvas does not have every Maple Learn feature, but makes quick work of fast error checking.
canvas := NewCanvas([Text(“My first canvas”), Math(3*x+2*y)]):
There are two more things I want to show you in this post: How to make a group have multiple cells (instead of just the one), and how to position your items on the canvas. Let’s start with group making.
To create a group with multiple cells, use the Group() command within the NewCanvas command, and separate the cells with commas, in a list. You don’t need to specify Text() or Math() when using Group().
canvas := NewCanvas([Group([“This is the first cell…”, “The second….”, “and the third.”])]):
At the end of any command/canvas element, within the brackets, you can define position=[x,y] to specify where on the canvas the object should go. You can adjust the precision pixel by pixel until you are happy with the layout.
When we put all these together, we get code that looks like this:
canvas := NewCanvas([
Group(["This is the first cell…", "The second…", "and the third."], position=[200,200]),
Text("This is text!", position=[400,400])]):
And in the end, your scripted document looks like this.
We hope this helps you get started with Maple Scripting. There will be another post on even more of what we can do with Maple Scripting, and how we can make these documents even more interactive. Let us know if there’s anything specific you want to see in that post!