Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- const ID_PREFIX = 'vp_tracker';
- const FOLDER_ID = ID_PREFIX + '_folder';
- // change this to false to make expressions visible
- const HIDDEN_EXPRESSIONS = true;
- // Github: https://github.com/SlimRunner
- // Twitter: @runner_slim
- let state = Calc.getState();
- let newExprs = [
- String.raw`X_{vpmin}`,
- String.raw`Y_{vpmin}`,
- String.raw`X_{vpmax}`,
- String.raw`Y_{vpmax}`
- ].map((expval, i) => {
- return {
- id: `${ID_PREFIX}_${i}`,
- latex: `${expval}=0`,
- folderId: FOLDER_ID,
- type: 'expression'
- };
- });
- newExprs.unshift({
- collapsed: true,
- secret: HIDDEN_EXPRESSIONS,
- id: FOLDER_ID,
- type: 'folder'
- });
- state.expressions.list.push(...newExprs);
- Calc.setState(state, {allowUndo: true});
- Calc.observe('graphpaperBounds',() => {
- // this happens each time the GraphPaper is updated in Desmos
- let mCoords = Calc.graphpaperBounds.mathCoordinates;
- Calc.setExpression({
- id: `${ID_PREFIX}_0`,
- latex: `X_{vpmin}=${mCoords.left}`
- });
- Calc.setExpression({
- id: `${ID_PREFIX}_1`,
- latex: `Y_{vpmin}=${mCoords.top}`
- });
- Calc.setExpression({
- id: `${ID_PREFIX}_2`,
- latex: `X_{vpmax}=${mCoords.right}`
- });
- Calc.setExpression({
- id: `${ID_PREFIX}_3`,
- latex: `Y_{vpmax}=${mCoords.bottom}`
- });
- });
- }());
Add Comment
Please, Sign In to add comment