Annotate - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DocumentTools[Canvas][Script]

  

Annotate

  

script action to annotate math on a canvas

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

Annotate(script,caption)

Annotate(script,caption,source)

Parameters

script

-

DocumentTools:-Canvas:-Script object

caption

-

string

source

-

(optional) Math record

Description

• 

The Annotate command adds message text next to math on a canvas.

• 

A "canvas" is an interactive section of a Maple document created by the NewCanvas command, or a shared web-based Maple Learn document.  See the Script command for a more complete description.

• 

The source option is an element of the array returned by GetMath.  It can be omitted if SetActive is used to specify the active math container prior to calling Annotate.

Examples

Demonstration Example

• 

In this example, we will insert a canvas, get the math from the canvas, and manually add annotations to the math input.

withDocumentTools:-Canvas:

• 

create the canvas:

cvNewCanvasSample Canvas,x+y:

ShowCanvascv,input=boxA,boxB

• 

get references to the math data in the canvas:

dataGetMath:

• 

look at the math property of the first element:

data1:-math

• 

create a script object and add some annotations

scScript:

Annotatesc,this is a sum,data1

Annotatesc,this is box A,data2

• 

loop through all of the math and annotate each element with its type

forelemindatadoAnnotatesc,This contains something of type ,whattypeelemmath,elemenddo:

Button Example

• 

In this example, we will define an application that allows user input and provides feedback.  The FindPrimes procedure will run when a button is pressed.  It will find all the math in the canvas area, and add annotations to the inputs.

FindPrimes := proc( canvas )
   uses DC=DocumentTools:-Canvas;
   local script := DC:-Script();
   for local m in DC:-GetMath(canvas) do  # get all the math in the canvas
       SetActive(script,m);    # set the location of the annotation
       if m:-math::integer and isprime(m:-math) then
           Annotate(script,"Good job, this is prime");   # annotate based on the given math
      else
           Annotate(script,"This is not prime");
      end if;
  end do;
  ToString(script);
end proc:

• 

Generate the canvas

withDocumentTools:-Canvas:

cvNewCanvasWrite Some Prime Numbers Anywhere,ScriptButtonCheck Your Page,FindPrimes,position=500,50:

• 

To test this within Maple, run:

ShowCanvascv

• 

To try this on the web using Maple Learn, execute:

ShareCanvascv

Compatibility

• 

The DocumentTools[Canvas][Script][Annotate] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

GetMath

Script

SetActive