-
Notifications
You must be signed in to change notification settings - Fork 3
Scripting of interactivity and animations
mkraska edited this page Dec 8, 2023
·
10 revisions
Subtopic of Moving objects by scripts
Basic Elements of Meclib scripting
- Create control points
- Assign callbacks for dragging
- Bind control points as sliders to lines or circles
- Create animation sequences
- Create groups for simultaneous movement of objects
- Create new points at the location of some object points and move the objects by callback of the control point
- Convert an object point to a control point
var st = objects[20]; st.p1.setAttribute({fixed:false, visible:true, name:""}) st.p2.setAttribute({fixed:false, visible:true, name:""})
-
moveTo()
linear movements to a given position during a given time. Can be given a callback which is executed when the animation is finished. https://jsxgraph.org/docs/symbols/JXG.CoordsElement.html#moveTo -
setTimeOut()
delays the execution of commands wrapped in this function -
moveAlong()
moves along the points in a list during a given time. Example
-
makeGlider()
assign a slide object to a point https://jsxgraph.uni-bayreuth.de/docs/symbols/JXG.CoordsElement.html#makeGlider
You can set a rotation center and a point or a set of them where the rotation can be controlled.
let g1 = board.create('group', [f1.p1, m1.p1, b1.p2, s1.p1]);
g1.setRotationCenter(f1.p1);
g1.setRotationPoints(m1.p1);
In order to try code snippets in jsfiddle,
- copy the code from the wiki page to the clipboard
- follow the link for the JSXGraph version you want to try
- Replace the code in the HTML section (contents of
<p hidden id="init">
) with the content of the clipboard