DocumentTools[Canvas][Script]
Annotate
script action to annotate math on a canvas
Calling Sequence
Parameters
Description
Examples
Compatibility
Annotate(script,caption)
Annotate(script,caption,source)
script
-
DocumentTools:-Canvas:-Script object
caption
string
source
(optional) Math record
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.
Demonstration Example
In this example, we will insert a canvas, get the math from the canvas, and manually add annotations to the math input.
with⁡DocumentTools:-Canvas:
create the canvas:
cv≔NewCanvas⁡Sample Canvas,x+y:
ShowCanvas⁡cv,input=boxA,boxB
get references to the math data in the canvas:
data≔GetMath⁡:
look at the math property of the first element:
data1:-math
create a script object and add some annotations
sc≔Script⁡:
Annotate⁡sc,this is a sum,data1
Annotate⁡sc,this is box A,data2
loop through all of the math and annotate each element with its type
forelemindatadoAnnotate⁡sc,This contains something of type ,whattype⁡elemmath,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
cv≔NewCanvas⁡Write Some Prime Numbers Anywhere,ScriptButton⁡Check Your Page,FindPrimes,position=500,50:
To test this within Maple, run:
ShowCanvas⁡cv
To try this on the web using Maple Learn , execute:
ShareCanvas⁡cv
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
Download Help Document
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル