1 /* 2 Copyright 2008-2016 3 Matthias Ehmann, 4 Michael Gerhaeuser, 5 Carsten Miller, 6 Bianca Valentin, 7 Alfred Wassermann, 8 Peter Wilfahrt 9 10 This file is part of JSXGraph. 11 12 JSXGraph is free software dual licensed under the GNU LGPL or MIT License. 13 14 You can redistribute it and/or modify it under the terms of the 15 16 * GNU Lesser General Public License as published by 17 the Free Software Foundation, either version 3 of the License, or 18 (at your option) any later version 19 OR 20 * MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT 21 22 JSXGraph is distributed in the hope that it will be useful, 23 but WITHOUT ANY WARRANTY; without even the implied warranty of 24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 GNU Lesser General Public License for more details. 26 27 You should have received a copy of the GNU Lesser General Public License and 28 the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/> 29 and <http://opensource.org/licenses/MIT/>. 30 */ 31 32 33 /*global JXG:true, define: true*/ 34 /*jslint nomen: true, plusplus: true*/ 35 36 /* depends: 37 jxg 38 base/constants 39 math/math 40 utils/color 41 utils/type 42 */ 43 44 define([ 45 'jxg', 'base/constants', 'math/math', 'utils/color', 'utils/type' 46 ], function (JXG, Const, Mat, Color, Type) { 47 48 "use strict"; 49 50 /** 51 * Options Namespace 52 * @description These are the default options of the board and of all geometry elements. 53 * @namespace 54 * @name JXG.Options 55 */ 56 JXG.Options = { 57 jc: { 58 enabled: true, 59 compile: true 60 }, 61 62 /* 63 * Options that are used directly within the board class 64 */ 65 board: { 66 /**#@+ 67 * @visprop 68 */ 69 70 //updateType: 'hierarchical', // 'all' 71 72 /** 73 * Bounding box of the visible area in user coordinates. 74 * It is an array consisting of four values: 75 * [x<sub>1</sub>, y<sub>1</sub>, x<sub>2</sub>, y<sub>2</sub>] 76 * 77 * The canvas will be spanned from the upper left corner (<sub>1</sub>, y<sub>1</sub>) 78 * to the lower right corner (x<sub>2</sub>, y<sub>2</sub>). 79 * 80 * @name JXG.Board#boundingbox 81 * @type Array 82 * @default [-5, 5, 5, -5] 83 */ 84 boundingBox: [-5, 5, 5, -5], 85 86 /** 87 * Additional zoom factor multiplied to {@link JXG.Board#zoomX} and {@link JXG.Board#zoomY}. 88 * 89 * @name JXG.Board#zoomFactor 90 * @type Number 91 * @default 1.0 92 */ 93 zoomFactor: 1, 94 95 /** 96 * Zoom factor in horizontal direction. 97 * 98 * @name JXG.Board#zoomX 99 * @see JXG.Board#zoomY 100 * @type Number 101 * @default 1.0 102 */ 103 zoomX: 1, 104 105 /** 106 * Zoom factor in vertical direction. 107 * 108 * @name JXG.Board#zoomY 109 * @see JXG.Board#zoomX 110 * @type Number 111 * @default 1.0 112 */ 113 zoomY: 1, 114 115 /** 116 * Show copyright string in canvas. 117 * 118 * @name JXG.Board#showCopyright 119 * @type Boolean 120 * @default true 121 */ 122 showCopyright: true, 123 124 /** 125 * Show default axis. 126 * If shown, the horizontal axis can be accessed via JXG.Board.defaultAxes.x, the 127 * vertical axis can be accessed via JXG.Board.defaultAxes.y. Both axes have a sub-element "defaultTicks". 128 * 129 * @name JXG.Board#axis 130 * @type Boolean 131 * @default false 132 */ 133 axis: false, 134 135 /** 136 * Display of navigation arrows and zoom buttons 137 * 138 * @name JXG.Board#showNavigation 139 * @type Boolean 140 * @default true 141 */ 142 showNavigation: true, 143 144 /** 145 * Show a button to force reload of a construction. 146 * Works only with the JessieCode tag 147 * 148 * @name JXG.Board#showReload 149 * @type Boolean 150 * @default false 151 */ 152 showReload: false, 153 154 /** 155 * Show a button which allows to clear all traces of a board. 156 * 157 * @name JXG.Board#showClearTraces 158 * @type Boolean 159 * @default false 160 */ 161 showClearTraces: false, 162 163 /** 164 * If set to true the bounding box might be changed such that 165 * the ratio of width and height of the hosting HTML div is equal 166 * to the ratio of wifth and height of the bounding box. 167 * 168 * This is necessary if circles should look like circles and not 169 * like ellipses. It is recommended to set keepAspectRatio = true 170 * for geometric applets. For function plotting keepAspectRatio = false 171 * might be the better choice. 172 * 173 * @name JXG.Board#keepAspectRatio 174 * @see JXG.Board#boundingbox 175 * @see JXG.Board#setBoundingBox 176 * @type Boolean 177 * @default false 178 */ 179 keepAspectRatio: false, 180 181 /** 182 * If set true and 183 * hasPoint() is true for both an element and it's label, 184 * the element (and not the label) is taken as drag element. 185 * 186 * If set false and hasPoint() is true for both an element and it's label, 187 * the label is taken (if it is on a higher layer than the element) 188 * 189 * @name JXG.Board#ignoreLabels 190 * @type Booelan 191 * @default true 192 */ 193 ignoreLabels: true, 194 195 /** 196 * Maximum number of digits in automatic label generation. 197 * For example, if set to 1 automatic point labels end at "Z". 198 * If set to 2, point labels end at "ZZ". 199 * 200 * @name JXG.Board#maxNameLength 201 * @see JXG.Board#generateName 202 * @type Number 203 * @default 1 204 */ 205 maxNameLength: 1, 206 207 /** 208 * Supply the document object. Defaults to window.document 209 * 210 * @name JXG.Board#document 211 * @type DOM object 212 * @default false (meaning window.document) 213 */ 214 document: false, 215 216 /** 217 * If true the first element of the set JXG.board.objects having hasPoint==true is taken as drag element. 218 * 219 * @name JXG.Board#takeFirst 220 * @type Boolean 221 * @default false 222 */ 223 takeFirst: false, 224 225 /** 226 * If true, when read from a file or string - the size of the div can be changed by the construction text. 227 * 228 * @name JXG.Board#takeSizeFromFile 229 * @type Boolean 230 * @default false 231 */ 232 takeSizeFromFile: false, 233 234 /** 235 * Default rendering engine. Possible values are 'svg', 'canvas', 'vml', 'no'. 236 * If the rendering engine is not available JSXGraph tries to detect a different engine. 237 * 238 * @name JXG.Board#renderer 239 * @type String 240 * @default 'svg' 241 */ 242 renderer: 'svg', 243 244 /** 245 * Time (in msec) between two animation steps. Used in 246 * {@link JXG.CoordsElement#moveAlong}, {@link JXG.CoordsElement#moveTo} and {@link JXG.CoordsElement#visit}. 247 * 248 * @name JXG.Board#animationDelay 249 * @type Number 250 * @default 35 251 * @see JXG.CoordsElement#moveAlong 252 * @see JXG.CoordsElement#moveTo 253 * @see JXG.CoordsElement#visit 254 */ 255 animationDelay: 35, 256 257 /** 258 * Allow user interaction by registering mouse and touch events. 259 * 260 * @name JXG.Board#registerEvents 261 * @type Boolean 262 * @default true 263 */ 264 registerEvents: true, 265 266 /** 267 * Change redraw strategy in SVG rendering engine. 268 * 269 * If set to 'svg', before every redrawing of the JSXGraph construction 270 * the SVG sub-tree of the DOM tree is taken out of the DOM. 271 * 272 * If set to 'all', before every redrawing of the JSXGraph construction the 273 * complete DOM tree is taken out of the DOM. 274 * If set to 'none' the redrawing is done in-place. 275 * 276 * Using 'svg' or 'all' speeds up the update process considerably. The risk 277 * is that if there is an exception, only a white div or window is left. 278 * 279 * @name JXG.Board#name 280 * @type String 281 * @default 'svg' 282 */ 283 minimizeReflow: 'svg', 284 285 /** 286 * A number that will be added to the absolute position of the board used in mouse coordinate 287 * calculations in {@link JXG.Board#getCoordsTopLeftCorner}. 288 * 289 * @name JXG.Board#offsetX 290 * @see JXG.Board#offsetY 291 * @type Number 292 * @default 0 293 */ 294 offsetX: 0, 295 296 /** 297 * A number that will be added to the absolute position of the board used in mouse coordinate 298 * calculations in {@link JXG.Board#getCoordsTopLeftCorner}. 299 * 300 * @name JXG.Board#offsetY 301 * @see JXG.Board#offsetX 302 * @type Number 303 * @default 0 304 */ 305 offsetY: 0, 306 307 /** 308 * Control the possibilities for zoom interaction. 309 * 310 * Possible sub-attributes with default values are: 311 * <pre> 312 * zoom: { 313 * factorX: 1.25, // horizontal zoom factor (multiplied to {@link JXG.Board#zoomX}) 314 * factorY: 1.25, // vertical zoom factor (multiplied to {@link JXG.Board#zoomY}) 315 * wheel: false, // allow zooming by mouse wheel or 316 * // by pinch-to-toom gesture on touch devices 317 * needshift: false, // mouse wheel zooming needs pressing of the shift key 318 * min: 0.001 // minimal values of {@link JXG.Board#zoomX} and {@link JXG.Board#zoomY}, limits zoomOut 319 * max: 1000.0 // maximal values of {@link JXG.Board#zoomX} and {@link JXG.Board#zoomY}, limits zoomIn 320 * } 321 * </pre> 322 * 323 * Deprecated: zoom.eps which is superseded by zoom.min 324 * 325 * @name JXG.Board#zoom 326 * @type Object 327 * @default 328 */ 329 zoom: { 330 factorX: 1.25, 331 factorY: 1.25, 332 wheel: false, 333 needshift: false, 334 min: 0.0001, 335 max: 10000.0 336 }, 337 338 /** 339 * Control the possibilities for panning interaction (i.e. moving the origin). 340 * 341 * Possible sub-attributes with default values are: 342 * <pre> 343 * pan: { 344 * enabled: true // Allow panning 345 * needTwoFingers: true, // panning is done with two fingers on touch devices 346 * needshift: true, // mouse panning needs pressing of the shift key 347 * } 348 * </pre> 349 * 350 * @name JXG.Board#pan 351 * @type Object 352 * @default 353 */ 354 pan: { 355 needShift: true, 356 needTwoFingers: true, 357 enabled: true 358 }, 359 360 selection: { 361 enabled: true, 362 name: 'selectionPolygon', 363 needShift: false, 364 needCtrl: true, 365 withLines: false, 366 vertices: { 367 visible: false 368 }, 369 fillColor: '#ffff00', 370 visible: false 371 } 372 /**#@-*/ 373 }, 374 375 /** 376 * Options that are used by the navigation bar. 377 * 378 * Default values are 379 * <pre> 380 * JXG.Option.navbar: { 381 * strokeColor: '#333333', 382 * fillColor: 'transparent', 383 * highlightFillColor: '#aaaaaa', 384 * padding: '2px', 385 * position: 'absolute', 386 * fontSize: '14px', 387 * cursor: 'pointer', 388 * zIndex: '100', 389 * right: '5px', 390 * bottom: '5px' 391 * }, 392 * </pre> 393 */ 394 navbar: { 395 strokeColor: '#333333', //'#aaaaaa', 396 fillColor: 'transparent', //#f5f5f5', 397 highlightFillColor: '#aaaaaa', 398 padding: '2px', 399 position: 'absolute', 400 fontSize: '14px', 401 cursor: 'pointer', 402 zIndex: '100', 403 right: '5px', 404 bottom: '5px' 405 //border: 'none 1px black', 406 //borderRadius: '4px' 407 }, 408 409 /* 410 * Generic options used by {@link JXG.GeometryElement} 411 */ 412 elements: { 413 // the following tag is a meta tag: http://code.google.com/p/jsdoc-toolkit/wiki/MetaTags 414 415 /**#@+ 416 * @visprop 417 */ 418 419 /** 420 * The stroke color of the given geometry element. 421 * @type String 422 * @name JXG.GeometryElement#strokeColor 423 * @see JXG.GeometryElement#highlightStrokeColor 424 * @see JXG.GeometryElement#strokeWidth 425 * @see JXG.GeometryElement#strokeOpacity 426 * @see JXG.GeometryElement#highlightStrokeOpacity 427 * @default {@link JXG.Options.elements.color#strokeColor} 428 */ 429 strokeColor: '#0000ff', 430 431 /** 432 * The stroke color of the given geometry element when the user moves the mouse over it. 433 * @type String 434 * @name JXG.GeometryElement#highlightStrokeColor 435 * @see JXG.GeometryElement#strokeColor 436 * @see JXG.GeometryElement#strokeWidth 437 * @see JXG.GeometryElement#strokeOpacity 438 * @see JXG.GeometryElement#highlightStrokeOpacity 439 * @default {@link JXG.Options.elements.color#highlightStrokeColor} 440 */ 441 highlightStrokeColor: '#C3D9FF', 442 443 /** 444 * The fill color of this geometry element. 445 * @type String 446 * @name JXG.GeometryElement#fillColor 447 * @see JXG.GeometryElement#highlightFillColor 448 * @see JXG.GeometryElement#fillOpacity 449 * @see JXG.GeometryElement#highlightFillOpacity 450 * @default {@link JXG.Options.elements.color#fillColor} 451 */ 452 fillColor: 'red', 453 454 /** 455 * The fill color of the given geometry element when the mouse is pointed over it. 456 * @type String 457 * @name JXG.GeometryElement#highlightFillColor 458 * @see JXG.GeometryElement#fillColor 459 * @see JXG.GeometryElement#fillOpacity 460 * @see JXG.GeometryElement#highlightFillOpacity 461 * @default {@link JXG.Options.elements.color#highlightFillColor} 462 */ 463 highlightFillColor: 'none', 464 465 /** 466 * Opacity for element's stroke color. 467 * @type number 468 * @name JXG.GeometryElement#strokeOpacity 469 * @see JXG.GeometryElement#strokeColor 470 * @see JXG.GeometryElement#highlightStrokeColor 471 * @see JXG.GeometryElement#strokeWidth 472 * @see JXG.GeometryElement#highlightStrokeOpacity 473 * @default {@link JXG.Options.elements#strokeOpacity} 474 */ 475 strokeOpacity: 1, 476 477 /** 478 * Opacity for stroke color when the object is highlighted. 479 * @type number 480 * @name JXG.GeometryElement#highlightStrokeOpacity 481 * @see JXG.GeometryElement#strokeColor 482 * @see JXG.GeometryElement#highlightStrokeColor 483 * @see JXG.GeometryElement#strokeWidth 484 * @see JXG.GeometryElement#strokeOpacity 485 * @default {@link JXG.Options.elements#highlightStrokeOpacity} 486 */ 487 highlightStrokeOpacity: 1, 488 489 /** 490 * Opacity for fill color. 491 * @type number 492 * @name JXG.GeometryElement#fillOpacity 493 * @see JXG.GeometryElement#fillColor 494 * @see JXG.GeometryElement#highlightFillColor 495 * @see JXG.GeometryElement#highlightFillOpacity 496 * @default {@link JXG.Options.elements.color#fillOpacity} 497 */ 498 fillOpacity: 1, 499 500 /** 501 * Opacity for fill color when the object is highlighted. 502 * @type number 503 * @name JXG.GeometryElement#highlightFillOpacity 504 * @see JXG.GeometryElement#fillColor 505 * @see JXG.GeometryElement#highlightFillColor 506 * @see JXG.GeometryElement#fillOpacity 507 * @default {@link JXG.Options.elements.color#highlightFillOpacity} 508 */ 509 highlightFillOpacity: 1, 510 511 /** 512 * Width of the element's stroke. 513 * @type number 514 * @name JXG.GeometryElement#strokeWidth 515 * @see JXG.GeometryElement#strokeColor 516 * @see JXG.GeometryElement#highlightStrokeColor 517 * @see JXG.GeometryElement#strokeOpacity 518 * @see JXG.GeometryElement#highlightStrokeOpacity 519 * @default {@link JXG.Options.elements#strokeWidth} 520 */ 521 strokeWidth: 2, 522 523 /** 524 * Width of the element's stroke when the mouse is pointed over it. 525 * @type number 526 * @name JXG.GeometryElement#highlightStrokeWidth 527 * @see JXG.GeometryElement#strokeColor 528 * @see JXG.GeometryElement#highlightStrokeColor 529 * @see JXG.GeometryElement#strokeOpacity 530 * @see JXG.GeometryElement#highlightStrokeOpacity 531 * @see JXG.GeometryElement#highlightFillColor 532 * @default {@link JXG.Options.elements#strokeWidth} 533 */ 534 highlightStrokeWidth: 2, 535 536 537 /** 538 * If true the element is fixed and can not be dragged around. The element 539 * will be repositioned on zoom and moveOrigin events. 540 * @type Boolean 541 * @default false 542 * @name JXG.GeometryElement#fixed 543 */ 544 fixed: false, 545 546 /** 547 * If true the element is fixed and can not be dragged around. The element 548 * will even stay at its position on zoom and moveOrigin events. 549 * Only free elements like points, texts, curves can be frozen. 550 * @type Boolean 551 * @default false 552 * @name JXG.GeometryElement#frozen 553 */ 554 frozen: false, 555 556 /** 557 * If true a label will display the element's name. 558 * @type Boolean 559 * @default false 560 * @name JXG.GeometryElement#withLabel 561 */ 562 withLabel: false, 563 564 /** 565 * If false the element won't be visible on the board, otherwise it is shown. 566 * @type boolean 567 * @name JXG.GeometryElement#visible 568 * @see JXG.GeometryElement#hideElement 569 * @see JXG.GeometryElement#showElement 570 * @default true 571 */ 572 visible: true, 573 574 /** 575 * A private element will be inaccessible in certain environments, e.g. a graphical user interface. 576 * @default false 577 */ 578 priv: false, 579 580 /** 581 * Display layer which will contain the element. 582 * @see JXG.Options#layer 583 * @default See {@link JXG.Options#layer} 584 */ 585 layer: 0, 586 587 /** 588 * Determines the elements border-style. 589 * Possible values are: 590 * <ul><li>0 for a solid line</li> 591 * <li>1 for a dotted line</li> 592 * <li>2 for a line with small dashes</li> 593 594 595 * <li>3 for a line with medium dashes</li> 596 * <li>4 for a line with big dashes</li> 597 * <li>5 for a line with alternating medium and big dashes and large gaps</li> 598 * <li>6 for a line with alternating medium and big dashes and small gaps</li></ul> 599 * @type Number 600 * @name JXG.GeometryElement#dash 601 * @default 0 602 */ 603 dash: 0, 604 605 /** 606 * If true the element will get a shadow. 607 * @type boolean 608 * @name JXG.GeometryElement#shadow 609 * @default false 610 */ 611 shadow: false, 612 613 /** 614 * If true the element will be traced, i.e. on every movement the element will be copied 615 * to the background. Use {@link JXG.GeometryElement#clearTrace} to delete the trace elements. 616 * @see JXG.GeometryElement#clearTrace 617 * @see JXG.GeometryElement#traces 618 * @see JXG.GeometryElement#numTraces 619 * @type Boolean 620 * @default false 621 * @name JXG.GeometryElement#trace 622 */ 623 trace: false, 624 625 /** 626 * Extra visual properties for traces of an element 627 * @type Object 628 * @see JXG.GeometryElement#trace 629 * @name JXG.GeometryElement#traceAttributes 630 */ 631 traceAttributes: {}, 632 633 /** 634 * 635 * @type Boolean 636 * @default true 637 * @name JXG.GeometryElement#highlight 638 */ 639 highlight: true, 640 641 /** 642 * If this is set to true, the element is updated in every update 643 * call of the board. If set to false, the element is updated only after 644 * zoom events or more generally, when the bounding box has been changed. 645 * Examples for the latter behaviour should be axes. 646 * @type Boolean 647 * @default true 648 * @see JXG.GeometryElement#needsRegularUpdate 649 * @name JXG.GeometryElement#needsRegularUpdate 650 */ 651 needsRegularUpdate: true, 652 653 /** 654 * Snaps the element or its parents to the grid. Currently only relevant for points, circles, 655 * and lines. Points are snapped to grid directly, on circles and lines it's only the parent 656 * points that are snapped 657 * @type Boolean 658 * @default false 659 * @name JXG.GeometryElement#snapToGrid 660 */ 661 snapToGrid: false, 662 663 /** 664 * Determines whether two-finger manipulation of this object may change its size. 665 * If set to false, the object is only rotated and translated. 666 * @type Boolean 667 * @default true 668 * @name JXG.GeometryElement#scalable 669 */ 670 scalable: true, 671 672 /*draft options */ 673 draft: { 674 /** 675 * If true the element will be drawn in grey scale colors to visualize that it's only a draft. 676 * @type boolean 677 * @name JXG.GeometryElement#draft 678 * @default {@link JXG.Options.elements.draft#draft} 679 */ 680 draft: false, 681 strokeColor: '#565656', 682 fillColor: '#565656', 683 strokeOpacity: 0.8, 684 fillOpacity: 0.8, 685 strokeWidth: 1 686 }, 687 688 /** 689 * @private 690 * By default, an element is not a label. Do not change this. 691 */ 692 isLabel: false 693 // close the meta tag 694 /**#@-*/ 695 }, 696 697 /* 698 * Generic options used by {@link JXG.Ticks} 699 */ 700 ticks: { 701 /**#@+ 702 * @visprop 703 */ 704 705 /** 706 * A function that expects two {@link JXG.Coords}, the first one representing the coordinates of the 707 * tick that is to be labeled, the second one the coordinates of the center (the tick with position 0). 708 * 709 * @type function 710 * @name Ticks#generateLabelText 711 */ 712 generateLabelText: null, 713 714 /** 715 * A function that expects two {@link JXG.Coords}, the first one representing the coordinates of the 716 * tick that is to be labeled, the second one the coordinates of the center (the tick with position 0). 717 * 718 * @deprecated Use {@link JGX.Options@generateLabelValue} 719 * @type function 720 * @name Ticks#generateLabelValue 721 */ 722 generateLabelValue: null, 723 724 /** 725 * Draw labels yes/no 726 * 727 * @type Boolean 728 * @name Ticks#drawLabels 729 * @default false 730 */ 731 drawLabels: false, 732 label: { 733 }, 734 735 /** 736 * Use the unicode character 0x2212, i.e. the HTML entity − as minus sign. 737 * That is −1 instead of -1. 738 * 739 * @type Boolean 740 * @name Ticks#useUnicodeMinus 741 * @default true 742 */ 743 useUnicodeMinus: true, 744 745 /** 746 * Determine the position of the tick with value 0. 'left' means point1 of the line, 'right' means point2, 747 * and 'middle' is equivalent to the midpoint of the defining points. This attribute is ignored if the parent 748 * line is of type axis and is parallel to either the x (i.e. y = 0) or the y (i.e. x = 0) axis. 749 * 750 * @type String 751 * @name Ticks#anchor 752 * @default 'left' 753 */ 754 anchor: 'left', 755 756 /** 757 * Draw the zero tick, that lies at line.point1? 758 * 759 * @type Boolean 760 * @name Ticks#drawZero 761 * @default false 762 */ 763 drawZero: false, 764 765 /** 766 * If the distance between two ticks is too big we could insert new ticks. If insertTicks 767 * is <tt>true</tt>, we'll do so, otherwise we leave the distance as is. 768 * This option is ignored if equidistant is false. In the example below the distance between 769 * two ticks is given as <tt>1</tt> but because insertTicks is set to true many ticks will 770 * be omitted in the rendering process to keep the display clear. 771 * 772 * @type Boolean 773 * @name Ticks#insertTicks 774 * @see Ticks#equidistant 775 * @see Ticks#minTicksDistance 776 * @default false 777 * @example 778 * // Create an axis providing two coord pairs. 779 * var p1 = board.create('point', [0, 0]); 780 * var p2 = board.create('point', [50, 25]); 781 * var l1 = board.create('line', [p1, p2]); 782 * var t = board.create('ticks', [l1, 1], { 783 * insertTicks: true, 784 * majorHeight: -1, 785 * label: { 786 * offset: [4, -9] 787 * }, 788 * drawLabels: true 789 * }); 790 * </pre><div class="jxgbox"id="2f6fb842-40bd-4223-aa28-3e9369d2097f" style="width: 300px; height: 300px;"></div> 791 * <script type="text/javascript"> 792 * (function () { 793 * var board = JXG.JSXGraph.initBoard('2f6fb842-40bd-4223-aa28-3e9369d2097f', {boundingbox: [-100, 70, 70, -100], showcopyright: false, shownavigation: false}); 794 * var p1 = board.create('point', [0, 0]); 795 * var p2 = board.create('point', [50, 25]); 796 * var l1 = board.create('line', [p1, p2]); 797 * var t = board.create('ticks', [l1, 1], {insertTicks: true, majorHeight: -1, label: {offset: [4, -9]}, drawLabels: true}); 798 * })(); 799 * </script><pre> 800 */ 801 insertTicks: false, 802 minTicksDistance: 10, 803 804 /** 805 * Total height of a minor tick. If negative the full height of the board is taken. 806 * 807 * @type Number 808 * @name Ticks#minorHeight 809 * @default 4 810 */ 811 minorHeight: 4, 812 813 /** 814 * Total height of a major tick. If negative the full height of the board is taken. 815 * 816 * @type Number 817 * @name Ticks#majorHeight 818 * @default 10 819 */ 820 majorHeight: 10, 821 822 /** 823 * Decides in which direction finite ticks are visible. Possible values are 0=false or 1=true. 824 * In case of [0,1] the tick is only visible to the right of the line. In case of 825 * [1,0] the tick is only visible to the left of the line. 826 * 827 * @type Array 828 * @name Ticks#tickEndings 829 * @default [1, 1] 830 */ 831 tickEndings: [1, 1], 832 833 /** 834 * The number of minor ticks between two major ticks. 835 * @type Number 836 * @name Ticks#minorTicks 837 * @default 4 838 */ 839 minorTicks: 4, 840 841 /** 842 * Scale the ticks but not the tick labels. 843 * @type Number 844 * @default 1 845 * @name Ticks#scale 846 * @see Ticks#scaleSymbol 847 */ 848 scale: 1, 849 850 /** 851 * A string that is appended to every tick, used to represent the scale 852 * factor given in {@link JXG.Ticks#scaleSymbol}. 853 * 854 * @type String 855 * @default '' 856 * @name Ticks#scaleSymbol 857 * @see Ticks#scale 858 */ 859 scaleSymbol: '', 860 861 /** 862 * User defined labels for special ticks. Instead of the i-th tick's position, the i-th string stored in this array 863 * is shown. If the number of strings in this array is less than the number of special ticks, the tick's position is 864 * shown as a fallback. 865 * 866 * @type Array 867 * @name Ticks#labels 868 * @default [] 869 */ 870 labels: [], 871 872 /** 873 * The maximum number of characters a tick label can use. 874 * 875 * @type Number 876 * @name Ticks#maxLabelLength 877 * @see Ticks#precision 878 * @default 5 879 */ 880 maxLabelLength: 5, 881 882 /** 883 * If a label exceeds {@link JXG.Ticks#maxLabelLength} this determines the precision used to shorten the tick label. 884 * 885 * @type Number 886 * @name Ticks#precision 887 * @see Ticks#maxLabelLength 888 * @default 3 889 */ 890 precision: 3, 891 892 /** 893 * The default distance between two ticks. Please be aware that this value does not have 894 * to be used if {@link JXG.Ticks#insertTicks} is set to true. 895 * 896 * @type Number 897 * @name Ticks#ticksDistance 898 * @see Ticks#equidistant 899 * @see Ticks#insertTicks 900 * @default 1 901 */ 902 ticksDistance: 1, 903 strokeOpacity: 1, 904 strokeWidth: 1, 905 strokeColor: 'black', 906 highlightStrokeColor: '#888888', 907 908 /** 909 * Whether line boundaries should be counted or not in the lower and upper bounds when 910 * creating ticks. 911 * 912 * @type Boolean 913 * @name Ticks#includeBoundaries 914 * @default false 915 */ 916 includeBoundaries: false 917 // close the meta tag 918 /**#@-*/ 919 }, 920 921 /* 922 * Generic options used by {@link JXG.Hatch} 923 */ 924 hatch: { 925 drawLabels: false, 926 drawZero: true, 927 majorHeight: 20, 928 anchor: 'middle', 929 strokeWidth: 2, 930 strokeColor: 'blue', 931 ticksDistance: 0.2 932 }, 933 934 /** 935 * Precision options. 936 * 937 * The default values are 938 * <pre> 939 * JXG.Options.precision: { 940 * touch: 30, 941 * touchMax: 100, 942 * mouse: 4, 943 * epsilon: 0.0001, 944 * hasPoint: 4 945 * } 946 * </pre> 947 */ 948 precision: { 949 touch: 30, 950 touchMax: 100, 951 mouse: 4, 952 epsilon: 0.0001, 953 hasPoint: 4 954 }, 955 956 /** 957 * Default ordering of the layers. 958 * 959 * The default values are 960 * <pre> 961 * JXG.Options.layer: { 962 * numlayers: 20, // only important in SVG 963 * text: 9, 964 * point: 9, 965 * glider: 9, 966 * arc: 8, 967 * line: 7, 968 * circle: 6, 969 * curve: 5, 970 * turtle: 5, 971 * polygon: 3, 972 * sector: 3, 973 * angle: 3, 974 * integral: 3, 975 * axis: 2, 976 * ticks: 2, 977 * grid: 1, 978 * image: 0, 979 * trace: 0 980 * } 981 * </pre> 982 */ 983 layer: { 984 numlayers: 20, // only important in SVG 985 text: 9, 986 point: 9, 987 glider: 9, 988 arc: 8, 989 line: 7, 990 circle: 6, 991 curve: 5, 992 turtle: 5, 993 polygon: 3, 994 sector: 3, 995 angle: 3, 996 integral: 3, 997 axis: 2, 998 ticks: 2, 999 grid: 1, 1000 image: 0, 1001 trace: 0 1002 }, 1003 1004 /* special angle options */ 1005 angle: { 1006 /**#@+ 1007 * @visprop 1008 */ 1009 1010 withLabel: true, 1011 1012 /** 1013 * Radius of the sector, displaying the angle. 1014 * 1015 * @type Number 1016 * @name Angle#radius 1017 * @default 0.5 1018 * @visprop 1019 */ 1020 radius: 0.5, 1021 1022 /** 1023 * Display type of the angle field. Possible values are 1024 * 'sector' or 'sectordot' or 'square' or 'none'. 1025 * 1026 * @type String 1027 * @default 'sector' 1028 * @name Angle#type 1029 * @visprop 1030 */ 1031 type: 'sector', 1032 1033 /** 1034 * Display type of the angle field in case of a right angle. Possible values are 1035 * 'sector' or 'sectordot' or 'square' or 'none'. 1036 * 1037 * @type String 1038 * @default square 1039 * @name Angle#orthoType 1040 * @see Angle#orthoSensitivity 1041 * @visprop 1042 */ 1043 orthoType: 'square', 1044 1045 /** 1046 * Sensitivity (in degrees) to declare an angle as right angle. 1047 * If the angle measure is inside this distance from a rigth angle, the orthoType 1048 * of the angle is used for display. 1049 * 1050 * @type Number 1051 * @default 1.0 1052 * @name Angle#orthoSensitivity 1053 * @see Angle#orthoType 1054 * @visprop 1055 */ 1056 orthoSensitivity: 1.0, 1057 1058 fillColor: '#FF7F00', 1059 highlightFillColor: '#FF7F00', 1060 strokeColor: '#FF7F00', 1061 fillOpacity: 0.3, 1062 highlightFillOpacity: 0.3, 1063 1064 /** 1065 * @deprecated 1066 */ 1067 radiuspoint: { 1068 withLabel: false, 1069 visible: false, 1070 name: '' 1071 }, 1072 /** 1073 * @deprecated 1074 */ 1075 pointsquare: { 1076 withLabel: false, 1077 visible: false, 1078 name: '' 1079 }, 1080 1081 dot: { 1082 visible: false, 1083 strokeColor: 'none', 1084 fillColor: 'black', 1085 size: 2, 1086 face: 'o', 1087 withLabel: false, 1088 name: '' 1089 }, 1090 label: { 1091 position: 'top', 1092 offset: [0, 0], 1093 strokeColor: '#0000FF' 1094 }, 1095 1096 arc: { 1097 visible: false 1098 } 1099 1100 /**#@-*/ 1101 }, 1102 1103 /* special arc options */ 1104 arc: { 1105 /**#@+ 1106 * @visprop 1107 */ 1108 1109 label: {}, 1110 firstArrow: false, 1111 lastArrow: false, 1112 fillColor: 'none', 1113 highlightFillColor: 'none', 1114 strokeColor: '#0000ff', 1115 highlightStrokeColor: '#C3D9FF', 1116 useDirection: false 1117 1118 /**#@-*/ 1119 }, 1120 1121 /* special axis options */ 1122 axis: { 1123 /**#@+ 1124 * @visprop 1125 */ 1126 1127 name: '', // By default, do not generate names for axes. 1128 needsRegularUpdate: false, // Axes only updated after zooming and moving of the origin. 1129 strokeWidth: 1, 1130 strokeColor: '#666666', 1131 highlightStrokeWidth: 1, 1132 highlightStrokeColor: '#888888', 1133 withTicks: true, 1134 straightFirst: true, 1135 straightLast: true, 1136 lastArrow: true, 1137 margin: -4, 1138 withLabel: false, 1139 scalable: false, 1140 1141 /** 1142 * Attributes for ticks of the axis. 1143 * 1144 * @type Ticks 1145 * @name Axis#ticks 1146 */ 1147 ticks: { 1148 label: { 1149 offset: [4, -12 + 3], // This seems to be a good offset for 12 point fonts 1150 parse: false, 1151 needsRegularUpdate: false, 1152 display: 'internal', 1153 layer: 9 1154 }, 1155 needsRegularUpdate: false, 1156 strokeWidth: 1, 1157 strokeColor: '#666666', 1158 highlightStrokeColor: '#888888', 1159 drawLabels: true, 1160 drawZero: false, 1161 insertTicks: true, 1162 minTicksDistance: 5, 1163 minorHeight: 10, // if <0: full width and height 1164 majorHeight: -1, // if <0: full width and height 1165 tickEndings: [0, 1], 1166 minorTicks: 4, 1167 ticksDistance: 1, // TODO doc 1168 strokeOpacity: 0.25 1169 }, 1170 1171 /** 1172 * Attributes for first point the axis. 1173 * 1174 * @type Point 1175 * @name Axis#point1 1176 */ 1177 point1: { // Default values for point1 if created by line 1178 needsRegularUpdate: false 1179 }, 1180 1181 /** 1182 * Attributes for second point the axis. 1183 * 1184 * @type Point 1185 * @name Axis#point2 1186 */ 1187 point2: { // Default values for point2 if created by line 1188 needsRegularUpdate: false 1189 }, 1190 1191 /** 1192 * Attributes for the axis label. 1193 * 1194 * @type Label 1195 * @name Axis#label 1196 */ 1197 label: { 1198 position: 'lft', 1199 offset: [10, 10] 1200 } 1201 /**#@-*/ 1202 }, 1203 1204 /* special options for angle bisector of 3 points */ 1205 bisector: { 1206 /**#@+ 1207 * @visprop 1208 */ 1209 1210 strokeColor: '#000000', // Bisector line 1211 1212 /** 1213 * Attributes for the helper point of the bisector. 1214 * 1215 * @type Point 1216 * @name Bisector#point 1217 */ 1218 point: { // Bisector point 1219 visible: false, 1220 fixed: false, 1221 withLabel: false, 1222 name: '' 1223 } 1224 1225 /**#@-*/ 1226 }, 1227 1228 /* special options for the 2 bisectors of 2 lines */ 1229 bisectorlines: { 1230 /**#@+ 1231 * @visprop 1232 */ 1233 1234 /** 1235 * Attributes for first line. 1236 * 1237 * @type Line 1238 * @name Bisectorlines#line1 1239 */ 1240 line1: { // 1241 strokeColor: 'black' 1242 }, 1243 1244 /** 1245 * Attributes for second line. 1246 * 1247 * @type Line 1248 * @name Bisectorlines#line2 1249 */ 1250 line2: { // 1251 strokeColor: 'black' 1252 } 1253 1254 /**#@-*/ 1255 }, 1256 1257 /* special button options */ 1258 button: { 1259 /**#@+ 1260 * @visprop 1261 */ 1262 1263 /** 1264 * Control the attribute "disabled" of the HTML button. 1265 * 1266 * @name disabled 1267 * @memberOf Button.prototype 1268 * 1269 * @type Boolean 1270 * @default false 1271 */ 1272 disabled: false, 1273 1274 /** 1275 * If true, the element is not placed into a foreignObject element. 1276 * Instead, the element is placed into a separate HTML div element "above" 1277 * the JSXGraph construction. 1278 * This is necessary to enable interaction. 1279 * The drawback is that a SVG export will not display this element. 1280 * 1281 * @type {Boolean} 1282 */ 1283 externalHTML: true 1284 1285 /**#@-*/ 1286 }, 1287 1288 /* special chart options */ 1289 chart: { 1290 /**#@+ 1291 * @visprop 1292 */ 1293 1294 chartStyle: 'line', 1295 colors: ['#B02B2C', '#3F4C6B', '#C79810', '#D15600', '#FFFF88', '#C3D9FF', '#4096EE', '#008C00'], 1296 highlightcolors: null, 1297 fillcolor: null, 1298 highlightonsector: false, 1299 highlightbysize: false, 1300 label: { 1301 } 1302 /**#@-*/ 1303 }, 1304 1305 /* special html slider options */ 1306 checkbox: { 1307 /**#@+ 1308 * @visprop 1309 */ 1310 1311 /** 1312 * Control the attribute "disabled" of the HTML checkbox. 1313 * 1314 * @name disabled 1315 * @memberOf Checkbox.prototype 1316 * 1317 * @type Boolean 1318 * @default false 1319 */ 1320 disabled: false, 1321 1322 /** 1323 * If true, the element is not placed into a foreignObject element. 1324 * Instead, the element is placed into a separate HTML div element "above" 1325 * the JSXGraph construction. 1326 * This is necessary to enable interaction. 1327 * The drawback is that a SVG export will not display this element. 1328 * 1329 * @type {Boolean} 1330 */ 1331 externalHTML: true 1332 1333 /**#@-*/ 1334 }, 1335 1336 /*special circle options */ 1337 circle: { 1338 /**#@+ 1339 * @visprop 1340 */ 1341 1342 /** 1343 * If <tt>true</tt>, moving the mouse over inner points triggers hasPoint. 1344 * 1345 * @see JXG.GeometryElement#hasPoint 1346 * @name Circle#hasInnerPoints 1347 * @type Boolean 1348 * @default false 1349 */ 1350 hasInnerPoints: false, 1351 1352 fillColor: 'none', 1353 highlightFillColor: 'none', 1354 strokeColor: '#0000ff', 1355 highlightStrokeColor: '#C3D9FF', 1356 1357 /** 1358 * Attributes for center point. 1359 * 1360 * @type Point 1361 * @name Circle#center 1362 */ 1363 center: { 1364 visible: false, 1365 withLabel: false, 1366 fixed: false, 1367 name: '' 1368 }, 1369 1370 /** 1371 * Attributes for circle label. 1372 * 1373 * @type Label 1374 * @name Circle#label 1375 */ 1376 label: { 1377 position: 'urt' 1378 } 1379 /**#@-*/ 1380 }, 1381 1382 /* special options for circumcircle of 3 points */ 1383 circumcircle: { 1384 /**#@+ 1385 * @visprop 1386 */ 1387 1388 fillColor: 'none', 1389 highlightFillColor: 'none', 1390 strokeColor: '#0000ff', 1391 highlightStrokeColor: '#C3D9FF', 1392 1393 /** 1394 * Attributes for center point. 1395 * 1396 * @type Point 1397 * @name Circumcircle#center 1398 */ 1399 center: { // center point 1400 visible: false, 1401 fixed: false, 1402 withLabel: false, 1403 name: '' 1404 } 1405 /**#@-*/ 1406 }, 1407 1408 circumcirclearc: { 1409 /**#@+ 1410 * @visprop 1411 */ 1412 1413 fillColor: 'none', 1414 highlightFillColor: 'none', 1415 strokeColor: '#0000ff', 1416 highlightStrokeColor: '#C3D9FF', 1417 1418 /** 1419 * Attributes for center point. 1420 * 1421 * @type Point 1422 * @name CircumcircleArc#center 1423 */ 1424 center: { 1425 visible: false, 1426 withLabel: false, 1427 fixed: false, 1428 name: '' 1429 } 1430 /**#@-*/ 1431 }, 1432 1433 /* special options for circumcircle sector of 3 points */ 1434 circumcirclesector: { 1435 /**#@+ 1436 * @visprop 1437 */ 1438 1439 useDirection: true, 1440 fillColor: '#00FF00', 1441 highlightFillColor: '#00FF00', 1442 fillOpacity: 0.3, 1443 highlightFillOpacity: 0.3, 1444 strokeColor: '#0000ff', 1445 highlightStrokeColor: '#C3D9FF', 1446 1447 /** 1448 * Attributes for center point. 1449 * 1450 * @type Point 1451 * @name Circle#point 1452 */ 1453 point: { 1454 visible: false, 1455 fixed: false, 1456 withLabel: false, 1457 name: '' 1458 } 1459 /**#@-*/ 1460 }, 1461 1462 /* special conic options */ 1463 conic: { 1464 /**#@+ 1465 * @visprop 1466 */ 1467 1468 fillColor: 'none', 1469 highlightFillColor: 'none', 1470 strokeColor: '#0000ff', 1471 highlightStrokeColor: '#C3D9FF', 1472 1473 /** 1474 * Attributes for foci points. 1475 * 1476 * @type Point 1477 * @name Conic#foci 1478 */ 1479 foci: { 1480 // points 1481 fixed: false, 1482 visible: false, 1483 withLabel: false, 1484 name: '' 1485 } 1486 /**#@-*/ 1487 }, 1488 1489 /* special curve options */ 1490 curve: { 1491 strokeWidth: 1, 1492 strokeColor: '#0000ff', 1493 fillColor: 'none', 1494 fixed: true, 1495 1496 useQDT: false, 1497 1498 /**#@+ 1499 * @visprop 1500 */ 1501 1502 /** 1503 * The data points of the curve are not connected with straight lines but with bezier curves. 1504 * @name Curve#handDrawing 1505 * @type Boolean 1506 * @default false 1507 */ 1508 handDrawing: false, 1509 1510 /** 1511 * The curveType is set in {@link JXG.Curve#generateTerm} and used in {@link JXG.Curve#updateCurve}. 1512 * Possible values are <ul> 1513 * <li>'none'</li> 1514 * <li>'plot': Data plot</li> 1515 * <li>'parameter': we can not distinguish function graphs and parameter curves</li> 1516 * <li>'functiongraph': function graph</li> 1517 * <li>'polar'</li> 1518 * <li>'implicit' (not yet)</li></ul> 1519 * Only parameter and plot are set directly. Polar is set with {@link JXG.GeometryElement#setAttribute} only. 1520 * @name Curve#curveType 1521 * @type String 1522 * @default null 1523 */ 1524 curveType: null, 1525 1526 /** 1527 * Apply Ramer-Douglas-Peuker smoothing. 1528 * 1529 * @type Boolean 1530 * @name Curve#RDPsmoothing 1531 * @default false 1532 */ 1533 RDPsmoothing: false, // Apply the Ramer-Douglas-Peuker algorithm 1534 1535 /** 1536 * Number of points used for plotting triggered by up events in case {@link Curve#doAdvancedPlot} is false. 1537 * 1538 * @name Curve#numberPointsHigh 1539 * @see Curve#doAdvancedPlot 1540 * @type Number 1541 * @default 1600 1542 */ 1543 numberPointsHigh: 1600, // Number of points on curves after mouseUp 1544 1545 /** 1546 * Number of points used for plotting triggered by move events in case {@link Curve#doAdvancedPlot} is false. 1547 * 1548 * @name Curve#numberPointsLow 1549 * @see Curve#doAdvancedPlot 1550 * @type Number 1551 * @default 400 1552 */ 1553 numberPointsLow: 400, // Number of points on curves after mousemove 1554 1555 /** 1556 * If true use a recursive bisection algorithm. 1557 * It is slower, but usually the result is better. It tries to detect jumps 1558 * and singularities. 1559 * 1560 * @name Curve#doAdvancedPlot 1561 * @type Boolean 1562 * @default true 1563 */ 1564 doAdvancedPlot: true, 1565 1566 /** 1567 * If true use the algorithm by Gillam and Hohenwarter, which was default until version 0.98. 1568 * 1569 * @name Curve#doAdvancedPlotOld 1570 * @see Curve#doAdvancedPlot 1571 * @type Boolean 1572 * @default false 1573 */ 1574 doAdvancedPlotOld: false, 1575 1576 /** 1577 * Attributes for circle label. 1578 * 1579 * @type Label 1580 * @name Circle#label 1581 */ 1582 label: { 1583 position: 'lft' 1584 } 1585 1586 /**#@-*/ 1587 }, 1588 1589 glider: { 1590 /**#@+ 1591 * @visprop 1592 */ 1593 1594 label: {} 1595 /**#@-*/ 1596 }, 1597 1598 /* special grid options */ 1599 grid: { 1600 /**#@+ 1601 * @visprop 1602 */ 1603 1604 /* grid styles */ 1605 needsRegularUpdate: false, 1606 hasGrid: false, 1607 gridX: 1, 1608 gridY: 1, 1609 //strokeColor: '#C0C0C0', 1610 strokeColor: '#C0C0C0', 1611 strokeOpacity: 0.5, 1612 strokeWidth: 1, 1613 dash: 0, // dashed grids slow down the iPad considerably 1614 /* snap to grid options */ 1615 1616 /** 1617 * @deprecated 1618 */ 1619 snapToGrid: false, 1620 /** 1621 * @deprecated 1622 */ 1623 snapSizeX: 10, 1624 /** 1625 * @deprecated 1626 */ 1627 snapSizeY: 10 1628 1629 /**#@-*/ 1630 }, 1631 1632 group: { 1633 needsRegularUpdate: true 1634 }, 1635 1636 /* special html slider options */ 1637 htmlslider: { 1638 /**#@+ 1639 * @visprop 1640 */ 1641 1642 /** 1643 * 1644 * These affect the DOM element input type="range". 1645 * The other attributes affect the DOM element div containing the range element. 1646 */ 1647 widthRange: 100, 1648 widthOut: 34, 1649 step: 0.01, 1650 1651 frozen: true, 1652 isLabel: false, 1653 strokeColor: 'black', 1654 display: 'html', 1655 anchorX: 'left', 1656 anchorY: 'middle', 1657 withLabel: false 1658 1659 /**#@-*/ 1660 }, 1661 1662 /* special image options */ 1663 image: { 1664 /**#@+ 1665 * @visprop 1666 */ 1667 1668 imageString: null, 1669 fillOpacity: 1.0, 1670 highlightFillOpacity: 0.6, 1671 1672 1673 /** 1674 * Defines the CSS class used by the image. CSS attributes defined in 1675 * this class will overwrite the corresponding JSXGraph attributes, e.g. 1676 * opacity. 1677 * The default CSS class is defined in jsxgraph.css. 1678 * 1679 * @name Image#cssClass 1680 * 1681 * @see Image#highlightCssClass 1682 * @type String 1683 * @default 'JXGimage' 1684 */ 1685 cssClass: 'JXGimage', 1686 1687 /** 1688 * Defines the CSS class used by the image when highlighted. 1689 * CSS attributes defined in this class will overwrite the 1690 * corresponding JSXGraph attributes, e.g. highlightFillOpacity. 1691 * The default CSS class is defined in jsxgraph.css. 1692 * 1693 * @name Image#highlightCssClass 1694 * 1695 * @see Image#cssClass 1696 * @type String 1697 * @default 'JXGimageHighlight' 1698 */ 1699 highlightCssClass: 'JXGimageHighlight', 1700 1701 /** 1702 * Image rotation in degrees. 1703 * 1704 * @name Image#rotate 1705 * @type Number 1706 * @default 0 1707 */ 1708 rotate: 0, 1709 1710 /** 1711 * Defines together with {@link Image#snapSizeY} the grid the image snaps on to. 1712 * The image will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 1713 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 1714 * of the default ticks of the default x axes of the board. 1715 * 1716 * @name Image#snapSizeX 1717 * 1718 * @see JXG.Point#snapToGrid 1719 * @see Image#snapSizeY 1720 * @see JXG.Board#defaultAxes 1721 * @type Number 1722 * @default 1 1723 */ 1724 snapSizeX: 1, 1725 1726 /** 1727 * Defines together with {@link Image#snapSizeX} the grid the image snaps on to. 1728 * The image will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 1729 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 1730 * of the default ticks of the default y axes of the board. 1731 * 1732 * @name Image#snapSizeY 1733 * 1734 * @see JXG.Point#snapToGrid 1735 * @see Image#snapSizeX 1736 * @see JXG.Board#defaultAxes 1737 * @type Number 1738 * @default 1 1739 */ 1740 snapSizeY: 1, 1741 1742 /** 1743 * List of attractor elements. If the distance of the image is less than 1744 * attractorDistance the image is made to glider of this element. 1745 * 1746 * @name Image#attractors 1747 * 1748 * @type array 1749 * @default empty 1750 */ 1751 attractors: [] 1752 1753 /**#@-*/ 1754 }, 1755 1756 /* special options for incircle of 3 points */ 1757 incircle: { 1758 /**#@+ 1759 * @visprop 1760 */ 1761 1762 fillColor: 'none', 1763 highlightFillColor: 'none', 1764 strokeColor: '#0000ff', 1765 highlightStrokeColor: '#C3D9FF', 1766 1767 /** 1768 * Attributes of circle center. 1769 * 1770 * @type Point 1771 * @name Incircle#center 1772 */ 1773 center: { // center point 1774 visible: false, 1775 fixed: false, 1776 withLabel: false, 1777 name: '' 1778 } 1779 /**#@-*/ 1780 }, 1781 1782 inequality: { 1783 /**#@+ 1784 * @visprop 1785 */ 1786 1787 fillColor: 'red', 1788 fillOpacity: 0.2, 1789 strokeColor: 'none', 1790 1791 /** 1792 * By default an inequality is less (or equal) than. Set inverse to <tt>true</tt> will consider the inequality 1793 * greater (or equal) than. 1794 * 1795 * @type Boolean 1796 * @default false 1797 * @name Inequality#inverse 1798 * @visprop 1799 */ 1800 inverse: false 1801 /**#@-*/ 1802 }, 1803 1804 infobox: { 1805 /**#@+ 1806 * @visprop 1807 */ 1808 1809 fontSize: 12, 1810 isLabel: false, 1811 strokeColor: '#bbbbbb', 1812 display: 'html', // 'html' or 'internal' 1813 anchorX: 'left', // 'left', 'middle', or 'right': horizontal alignment of the text. 1814 anchorY: 'middle', // 'top', 'middle', or 'bottom': vertical alignment of the text. 1815 cssClass: 'JXGinfobox', 1816 rotate: 0, // works for non-zero values only in combination with display=='internal' 1817 visible: true, 1818 parse: false, 1819 needsRegularUpdate: false 1820 1821 /**#@-*/ 1822 }, 1823 1824 /* special options for integral */ 1825 integral: { 1826 /**#@+ 1827 * @visprop 1828 */ 1829 1830 axis: 'x', // 'x' or 'y' 1831 withLabel: true, // Show integral value as text 1832 strokeWidth: 0, 1833 strokeOpacity: 0, 1834 fillOpacity: 0.8, 1835 1836 /** 1837 * Attributes of the (left) starting point of the integral. 1838 * 1839 * @type Point 1840 * @name Integral#curveLeft 1841 * @see Integral#baseLeft 1842 */ 1843 curveLeft: { // Start point 1844 visible: true, 1845 withLabel: false, 1846 layer: 9 1847 }, 1848 1849 /** 1850 * Attributes of the (left) base point of the integral. 1851 * 1852 * @type Point 1853 * @name Integral#baseLeft 1854 * @see Integral#curveLeft 1855 */ 1856 baseLeft: { // Start point 1857 visible: false, 1858 fixed: false, 1859 withLabel: false, 1860 name: '' 1861 }, 1862 1863 /** 1864 * Attributes of the (right) end point of the integral. 1865 * 1866 * @type Point 1867 * @name Integral#curveRight 1868 * @see Integral#baseRight 1869 */ 1870 curveRight: { // End point 1871 visible: true, 1872 withLabel: false, 1873 layer: 9 1874 }, 1875 1876 /** 1877 * Attributes of the (right) base point of the integral. 1878 * 1879 * @type Point 1880 * @name Integral#baseRight 1881 * @see Integral#curveRight 1882 */ 1883 baseRight: { // End point 1884 visible: false, 1885 fixed: false, 1886 withLabel: false, 1887 name: '' 1888 }, 1889 1890 /** 1891 * Attributes for integral label. 1892 * 1893 * @type Label 1894 * @name Integral#label 1895 */ 1896 label: { 1897 fontSize: 20 1898 } 1899 /**#@-*/ 1900 }, 1901 1902 /* special input options */ 1903 input: { 1904 /**#@+ 1905 * @visprop 1906 */ 1907 1908 /** 1909 * Control the attribute "disabled" of the HTML input field. 1910 * 1911 * @name disabled 1912 * @memberOf Input.prototype 1913 * 1914 * @type Boolean 1915 * @default false 1916 */ 1917 disabled: false, 1918 1919 /** 1920 * If true, the element is not placed into a foreignObject element. 1921 * Instead, the element is placed into a separate HTML div element "above" 1922 * the JSXGraph construction. 1923 * This is necessary to enable interaction. 1924 * The drawback is that a SVG export will not display this element. 1925 * 1926 * @type {Boolean} 1927 */ 1928 externalHTML: true 1929 1930 /**#@-*/ 1931 }, 1932 1933 /* special intersection point options */ 1934 intersection: { 1935 /**#@+ 1936 * @visprop 1937 */ 1938 1939 /** 1940 * Used in {@link JXG.Intersection}. 1941 * This flag sets the behaviour of intersection points of e.g. 1942 * two segments. If true, the intersection is treated as intersection of lines. If false 1943 * the intersection point exists if the segments intersect setwise. 1944 * 1945 * @name Intersection.alwaysIntersect 1946 * @type Boolean 1947 * @default true 1948 */ 1949 alwaysIntersect: true 1950 1951 /**#@-*/ 1952 }, 1953 1954 /* special label options */ 1955 label: { 1956 /**#@+ 1957 * @visprop 1958 */ 1959 1960 strokeColor: 'black', 1961 strokeOpacity: 1, 1962 highlightStrokeOpacity: 0.666666, 1963 highlightStrokeColor: 'black', 1964 1965 fixed: true, 1966 /** 1967 * Possible string values for the position of a label for 1968 * label anchor points are: 1969 * 'lft'|'rt'|'top'|'bot'|'ulft'|'urt'|'llft'|'lrt' 1970 * This is relevant for non-points: line, circle, curve. 1971 * 1972 * @type String 1973 * @default 'urt' 1974 * @name JXG.GeometryElement#label.position 1975 */ 1976 position: 'urt', 1977 1978 /** 1979 * Label offset from label anchor 1980 * The label anchor is determined by JXG.GeometryElement#label.position 1981 * 1982 * @type Array 1983 * @default [10,10] 1984 * @name JXG.GeometryElement#label.offset 1985 **/ 1986 offset: [10, 10] 1987 1988 /**#@-*/ 1989 }, 1990 1991 /* special legend options */ 1992 legend: { 1993 /** 1994 * @visprop 1995 */ 1996 style: 'vertical', 1997 labels: ['1', '2', '3', '4', '5', '6', '7', '8'], 1998 colors: ['#B02B2C', '#3F4C6B', '#C79810', '#D15600', '#FFFF88', '#C3D9FF', '#4096EE', '#008C00'] 1999 /**#@-*/ 2000 }, 2001 2002 /* special line options */ 2003 line: { 2004 /**#@+ 2005 * @visprop 2006 */ 2007 2008 /** 2009 * Line has an arrow head at the position of its first point or the corresponding 2010 * intersection with the canvas border. 2011 * 2012 * @name Line#firstArrow 2013 * @see Line#lastArrow 2014 * @see Line#touchFirstPoint 2015 * @type Boolean 2016 * @default false 2017 */ 2018 firstArrow: false, 2019 2020 /** 2021 * Line has an arrow head at the position of its second point or the corresponding 2022 * intersection with the canvas border. 2023 * 2024 * @name Line#lastArrow 2025 * @see Line#firstArrow 2026 * @see Line#touchLastPoint 2027 * @type Boolean 2028 * @default false 2029 */ 2030 lastArrow: false, 2031 2032 /** 2033 * This number (pixel value) controls where infinite lines end at the canvas border. If zero, the line 2034 * ends exactly at the border, if negative there is a margin to the inside, if positive the line 2035 * ends outside of the canvas (which is invisible). 2036 * @type {Number} 2037 * @default 0 2038 */ 2039 margin: 0, 2040 2041 /** 2042 * If true, line stretches infinitely in direction of its first point. 2043 * Otherwise it ends at point1. 2044 * 2045 * @name Line#straightFirst 2046 * @see Line#straightLast 2047 * @type Boolean 2048 * @default true 2049 */ 2050 straightFirst: true, 2051 2052 /** 2053 * If true, line stretches infinitely in direction of its second point. 2054 * Otherwise it ends at point2. 2055 * 2056 * @name Line#straightLast 2057 * @see Line#straightFirst 2058 * @type Boolean 2059 * @default true 2060 */ 2061 straightLast: true, 2062 2063 fillColor: 'none', // Important for VML on IE 2064 highlightFillColor: 'none', // Important for VML on IE 2065 strokeColor: '#0000ff', 2066 highlightStrokeColor: '#888888', 2067 withTicks: false, 2068 2069 /** 2070 * Attributes for first defining point of the line. 2071 * 2072 * @type Point 2073 * @name Line#point1 2074 */ 2075 point1: { // Default values for point1 if created by line 2076 visible: false, 2077 withLabel: false, 2078 fixed: false, 2079 name: '' 2080 }, 2081 2082 /** 2083 * Attributes for second defining point of the line. 2084 * 2085 * @type Point 2086 * @name Line#point2 2087 */ 2088 point2: { // Default values for point2 if created by line 2089 visible: false, 2090 withLabel: false, 2091 fixed: false, 2092 name: '' 2093 }, 2094 2095 /** 2096 * Attributes for ticks of the line. 2097 * 2098 * @type Ticks 2099 * @name Line#ticks 2100 */ 2101 ticks: { 2102 drawLabels: true, 2103 label: { 2104 offset: [4, -12 + 3] // This seems to be a good offset for 12 point fonts 2105 }, 2106 drawZero: false, 2107 insertTicks: false, 2108 minTicksDistance: 50, 2109 minorHeight: 4, // if <0: full width and height 2110 majorHeight: -1, // if <0: full width and height 2111 minorTicks: 4, 2112 defaultDistance: 1, 2113 strokeOpacity: 0.3 2114 }, 2115 2116 /** 2117 * Attributes for the line label. 2118 * 2119 * @type Label 2120 * @name Line#label 2121 */ 2122 label: { 2123 position: 'llft' 2124 }, 2125 2126 /** 2127 * If set to true, the point will snap to a grid defined by 2128 * {@link JXG.Point#snapSizeX} and {@link JXG.Point#snapSizeY}. 2129 * 2130 * @see Point#snapSizeX 2131 * @see Point#snapSizeY 2132 * @type Boolean 2133 * @name Line#snapToGrid 2134 * @default false 2135 */ 2136 snapToGrid: false, 2137 2138 /** 2139 * Defines together with {@link JXG.Point#snapSizeY} the grid the point snaps on to. 2140 * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 2141 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 2142 * of the default ticks of the default x axes of the board. 2143 * 2144 * @see Point#snapToGrid 2145 * @see Point#snapSizeY 2146 * @see JXG.Board#defaultAxes 2147 * @type Number 2148 * @name Line#snapSizeX 2149 * @default 1 2150 */ 2151 snapSizeX: 1, 2152 2153 /** 2154 * Defines together with {@link JXG.Point#snapSizeX} the grid the point snaps on to. 2155 * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 2156 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 2157 * of the default ticks of the default y axes of the board. 2158 * 2159 * @see Point#snapToGrid 2160 * @see Point#snapSizeX 2161 * @see Board#defaultAxes 2162 * @type Number 2163 * @name Line#snapSizeY 2164 * @default 1 2165 */ 2166 snapSizeY: 1, 2167 2168 /** 2169 * If set to true and {@link Line#firstArrow} is set to true, the arrow head will just touch 2170 * the circle line of the start point of the line. 2171 * 2172 * @see Line#firstArrow 2173 * @type Boolean 2174 * @name Line#touchFirstPoint 2175 * @default false 2176 */ 2177 touchFirstPoint: false, 2178 2179 /** 2180 * If set to true and {@link Line#lastArrow} is set to true, the arrow head will just touch 2181 * the circle line of the start point of the line. 2182 * @see Line#firstArrow 2183 * @type Boolean 2184 * @name Line#touchLastPoint 2185 * @default false 2186 */ 2187 touchLastPoint: false 2188 2189 /**#@-*/ 2190 }, 2191 2192 /* special options for locus curves */ 2193 locus: { 2194 /**#@+ 2195 * @visprop 2196 */ 2197 2198 translateToOrigin: false, 2199 translateTo10: false, 2200 stretch: false, 2201 toOrigin: null, 2202 to10: null 2203 /**#@-*/ 2204 }, 2205 2206 /* special options for normal lines */ 2207 normal: { 2208 /**#@+ 2209 * @visprop 2210 */ 2211 2212 strokeColor: '#000000', // normal line 2213 2214 /** 2215 * Attributes of helper point of normal. 2216 * 2217 * @type Point 2218 * @name Normal#point 2219 */ 2220 point: { 2221 visible: false, 2222 fixed: false, 2223 withLabel: false, 2224 name: '' 2225 } 2226 /**#@-*/ 2227 }, 2228 2229 /* special options for orthogonal projectionn points */ 2230 orthogonalprojection: { 2231 /**#@+ 2232 * @visprop 2233 */ 2234 2235 2236 /**#@-*/ 2237 }, 2238 2239 /* special options for parallel lines */ 2240 parallel: { 2241 /**#@+ 2242 * @visprop 2243 */ 2244 2245 strokeColor: '#000000', // Parallel line 2246 2247 /** 2248 * Attributes of helper point of normal. 2249 * 2250 * @type Point 2251 * @name Parallel#point 2252 */ 2253 point: { 2254 visible: false, 2255 fixed: false, 2256 withLabel: false, 2257 name: '' 2258 }, 2259 2260 label: { 2261 position: 'llft' 2262 } 2263 /**#@-*/ 2264 }, 2265 2266 /* special perpendicular options */ 2267 perpendicular: { 2268 /**#@+ 2269 * @visprop 2270 */ 2271 2272 strokeColor: '#000000', // Perpendicular line 2273 straightFirst: true, 2274 straightLast: true 2275 /**#@-*/ 2276 }, 2277 2278 /* special perpendicular options */ 2279 perpendicularsegment: { 2280 /**#@+ 2281 * @visprop 2282 */ 2283 2284 strokeColor: '#000000', // Perpendicular segment 2285 straightFirst: false, 2286 straightLast: false, 2287 point: { // Perpendicular point 2288 visible: false, 2289 fixed: true, 2290 withLabel: false, 2291 name: '' 2292 } 2293 /**#@-*/ 2294 }, 2295 2296 /* special point options */ 2297 point: { 2298 /**#@+ 2299 * @visprop 2300 */ 2301 2302 withLabel: true, 2303 label: {}, 2304 2305 /** 2306 * This attribute was used to determined the point layout. It was derived from GEONExT and was 2307 * replaced by {@link Point#face} and {@link Point#size}. 2308 * 2309 * @name Point#style 2310 * 2311 * @see Point#face 2312 * @see Point#size 2313 * @type Number 2314 * @default 5 2315 * @deprecated 2316 */ 2317 style: 5, 2318 2319 /** 2320 * There are different point styles which differ in appearance. 2321 * Posssible values are 2322 * <table><tr><th>Value</th></tr> 2323 * <tr><td>cross</td></tr> 2324 * <tr><td>circle</td></tr> 2325 * <tr><td>square</td></tr> 2326 * <tr><td>plus</td></tr> 2327 * <tr><td>diamond</td></tr> 2328 * <tr><td>triangleUp</td></tr> 2329 * <tr><td>triangleDown</td></tr> 2330 * <tr><td>triangleLeft</td></tr> 2331 * <tr><td>triangleRight</td></tr> 2332 * </table> 2333 * 2334 * @name Point#face 2335 * 2336 * @type string 2337 * @see Point#setStyle 2338 * @default circle 2339 */ 2340 face: 'o', 2341 2342 /** 2343 * Size of a point. 2344 * Means radius resp. half the width of a point (depending on the face). 2345 * 2346 * @name Point#size 2347 * 2348 * @see Point#face 2349 * @see Point#setStyle 2350 * @type number 2351 * @default 3 2352 */ 2353 size: 3, 2354 2355 fillColor: '#ff0000', 2356 highlightFillColor: '#EEEEEE', 2357 strokeWidth: 2, 2358 strokeColor: '#ff0000', 2359 highlightStrokeColor: '#C3D9FF', 2360 2361 /** 2362 * If true, the point size changes on zoom events. 2363 * 2364 * @type Boolean 2365 * @name Point#zoom 2366 * @default false 2367 * 2368 */ 2369 zoom: false, // Change the point size on zoom 2370 2371 /** 2372 * If true, the infobox is shown on mouse over, else not. 2373 * 2374 * @name Point#showInfobox 2375 * 2376 * @type Boolean 2377 * @default true 2378 */ 2379 showInfobox: true, 2380 2381 /** 2382 * Truncating rule for the digits in the infobox. 2383 * <ul> 2384 * <li>'auto': done automatically by JXG#autoDigits 2385 * <li>'none': no truncation 2386 * <li>number: use String.toFixed(); 2387 * </ul> 2388 * 2389 * @name Point#infoboxDigits 2390 * 2391 * @type String, Number 2392 * @default 'auto' 2393 */ 2394 infoboxDigits: 'auto', 2395 2396 draft: false, 2397 2398 /** 2399 * List of attractor elements. If the distance of the point is less than 2400 * attractorDistance the point is made to glider of this element. 2401 * 2402 * @name Point#attractors 2403 * 2404 * @type array 2405 * @default empty 2406 */ 2407 attractors: [], 2408 2409 /** 2410 * Unit for attractorDistance and snatchDistance, used for magnetized points and for snapToPoints. 2411 * Possible values are 'screen' and 'user. 2412 * 2413 * @name Point#attractorUnit 2414 * 2415 * @see Point#attractorDistance 2416 * @see Point#snatchDistance 2417 * @see Point#snapToPoints 2418 * @see Point#attractors 2419 * @type string 2420 * @default 'user' 2421 */ 2422 attractorUnit: 'user', // 'screen', 'user' 2423 2424 /** 2425 * If the distance of the point to one of its attractors is less 2426 * than this number the point will be a glider on this 2427 * attracting element. 2428 * If set to zero nothing happens. 2429 * 2430 * @name Point#attractorDistance 2431 * 2432 * @type number 2433 * @default 0.0 2434 */ 2435 attractorDistance: 0.0, 2436 2437 /** 2438 * If the distance of the point to one of its attractors is at least 2439 * this number the point will be released from being a glider on the 2440 * attracting element. 2441 * If set to zero nothing happens. 2442 * 2443 * @name Point#snatchDistance 2444 * 2445 * @type number 2446 * @default 0.0 2447 */ 2448 snatchDistance: 0.0, 2449 2450 /** 2451 * If set to true, the point will snap to a grid defined by 2452 * {@link Point#snapSizeX} and {@link Point#snapSizeY}. 2453 * 2454 * @name Point#snapToGrid 2455 * 2456 * @see JXG.Point#snapSizeX 2457 * @see JXG.Point#snapSizeY 2458 * @type Boolean 2459 * @default false 2460 */ 2461 snapToGrid: false, 2462 2463 /** 2464 * Defines together with {@link Point#snapSizeY} the grid the point snaps on to. 2465 * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 2466 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 2467 * of the default ticks of the default x axes of the board. 2468 * 2469 * @name Point#snapSizeX 2470 * 2471 * @see Point#snapToGrid 2472 * @see Point#snapSizeY 2473 * @see Board#defaultAxes 2474 * @type Number 2475 * @default 1 2476 */ 2477 snapSizeX: 1, 2478 2479 /** 2480 * Defines together with {@link Point#snapSizeX} the grid the point snaps on to. 2481 * The point will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 2482 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 2483 * of the default ticks of the default y axes of the board. 2484 * 2485 * @name Point#snapSizeY 2486 * 2487 * @see Point#snapToGrid 2488 * @see Point#snapSizeX 2489 * @see Board#defaultAxes 2490 * @type Number 2491 * @default 1 2492 */ 2493 snapSizeY: 1, 2494 2495 /** 2496 * If set to true, the point will snap to the nearest point in distance of 2497 * {@link Point#attractorDistance}. 2498 * 2499 * @name Point#snapToPoints 2500 * 2501 * @see Point#attractorDistance 2502 * @type Boolean 2503 * @default false 2504 */ 2505 snapToPoints: false, 2506 2507 /** 2508 * List of elements which are ignored by snapToPoints. 2509 * @name Point#ignoredSnapToPoints 2510 * 2511 * @type array 2512 * @default empty 2513 */ 2514 ignoredSnapToPoints: [] 2515 2516 /**#@-*/ 2517 }, 2518 2519 /* special polygon options */ 2520 polygon: { 2521 /**#@+ 2522 * @visprop 2523 */ 2524 2525 /** 2526 * If <tt>true</tt>, moving the mouse over inner points triggers hasPoint. 2527 * 2528 * @see JXG.GeometryElement#hasPoint 2529 * @name Polygon#hasInnerPoints 2530 * @type Boolean 2531 * @default false 2532 */ 2533 hasInnerPoints: false, 2534 2535 fillColor: '#00FF00', 2536 highlightFillColor: '#00FF00', 2537 fillOpacity: 0.3, 2538 highlightFillOpacity: 0.3, 2539 2540 /** 2541 * Is the polygon bordered by lines? 2542 * 2543 * @type Boolean 2544 * @name Polygon#withLines 2545 * @default true 2546 */ 2547 withLines: true, 2548 2549 /** 2550 * Attributes for the polygon border lines. 2551 * 2552 * @type Line 2553 * @name Polygon#borders 2554 */ 2555 borders: { 2556 withLabel: false, 2557 strokeWidth: 1, 2558 highlightStrokeWidth: 1, 2559 // Polygon layer + 1 2560 layer: 5, 2561 label: { 2562 position: 'top' 2563 } 2564 }, 2565 2566 /** 2567 * Attributes for the polygon vertices. 2568 * 2569 * @type Point 2570 * @name Polygon#vertices 2571 */ 2572 vertices: { 2573 layer: 9, 2574 withLabel: false, 2575 name: '', 2576 strokeColor: '#ff0000', 2577 fillColor: '#ff0000', 2578 fixed: false 2579 }, 2580 2581 /** 2582 * Attributes for the polygon label. 2583 * 2584 * @type Label 2585 * @name Polygon#label 2586 */ 2587 label: { 2588 offset: [0, 0] 2589 } 2590 2591 /**#@-*/ 2592 }, 2593 2594 /* special prescribed angle options */ 2595 prescribedangle: { 2596 /**#@+ 2597 * @visprop 2598 */ 2599 2600 /** 2601 * Attributes for the helper point of the prescribed angle. 2602 * 2603 * @type Point 2604 * @name PrescribedAngle#anglepoint 2605 */ 2606 anglepoint: { 2607 size: 2, 2608 visible: false, 2609 withLabel: false 2610 } 2611 2612 /**#@-*/ 2613 }, 2614 2615 /* special regular polygon options */ 2616 regularpolygon: { 2617 /**#@+ 2618 * @visprop 2619 */ 2620 2621 /** 2622 * If <tt>true</tt>, moving the mouse over inner points triggers hasPoint. 2623 * @see JXG.GeometryElement#hasPoint 2624 * 2625 * @name RegularPolygon#hasInnerPoints 2626 * @type Boolean 2627 * @default false 2628 */ 2629 hasInnerPoints: false, 2630 fillColor: '#00FF00', 2631 highlightFillColor: '#00FF00', 2632 fillOpacity: 0.3, 2633 highlightFillOpacity: 0.3, 2634 2635 /** 2636 * Is the polygon bordered by lines? 2637 * 2638 * @type Boolean 2639 * @name RegularPolygon#withLines 2640 * @default true 2641 */ 2642 withLines: true, 2643 2644 /** 2645 * Attributes for the polygon border lines. 2646 * 2647 * @type Line 2648 * @name RegularPolygon#borders 2649 */ 2650 borders: { 2651 withLabel: false, 2652 strokeWidth: 1, 2653 highlightStrokeWidth: 1, 2654 // Polygon layer + 1 2655 layer: 5, 2656 label: { 2657 position: 'top' 2658 } 2659 }, 2660 2661 /** 2662 * Attributes for the polygon vertices. 2663 * 2664 * @type Point 2665 * @name RegularPolygon#vertices 2666 */ 2667 vertices: { 2668 layer: 9, 2669 withLabel: true, 2670 strokeColor: '#ff0000', 2671 fillColor: '#ff0000', 2672 fixed: false 2673 }, 2674 2675 /** 2676 * Attributes for the polygon label. 2677 * 2678 * @type Label 2679 * @name Polygon#label 2680 */ 2681 label: { 2682 offset: [0, 0] 2683 } 2684 2685 /**#@-*/ 2686 }, 2687 2688 /* special options for riemann sums */ 2689 riemannsum: { 2690 /**#@+ 2691 * @visprop 2692 */ 2693 2694 withLabel: false, 2695 fillOpacity: 0.3, 2696 fillColor: '#ffff00' 2697 2698 /**#@-*/ 2699 }, 2700 2701 /* special sector options */ 2702 sector: { 2703 /**#@+ 2704 * @visprop 2705 */ 2706 2707 fillColor: '#00FF00', 2708 highlightFillColor: '#00FF00', 2709 fillOpacity: 0.3, 2710 highlightFillOpacity: 0.3, 2711 highlightOnSector: false, 2712 highlightStrokeWidth: 0, 2713 2714 /** 2715 * Attributes for sub-element arc. 2716 * 2717 * @type Arc 2718 * @name Sector#arc 2719 */ 2720 arc: { 2721 visible: false, 2722 fillColor: 'none' 2723 }, 2724 2725 /** 2726 * Attributes for helper point radiuspoint. 2727 * 2728 * @type Point 2729 * @name Sector#radiuspoint 2730 */ 2731 radiuspoint: { 2732 visible: false, 2733 withLabel: false 2734 }, 2735 2736 /** 2737 * Attributes for helper point center. 2738 * 2739 * @type Point 2740 * @name Sector#center 2741 */ 2742 center: { 2743 visible: false, 2744 withLabel: false 2745 }, 2746 2747 /** 2748 * Attributes for helper point anglepoint. 2749 * 2750 * @type Point 2751 * @name Sector#anglepoint 2752 */ 2753 anglepoint: { 2754 visible: false, 2755 withLabel: false 2756 }, 2757 2758 /** 2759 * Attributes for the sector label. 2760 * 2761 * @type Label 2762 * @name Sector#label 2763 */ 2764 label: { 2765 offset: [0, 0] 2766 } 2767 2768 /**#@-*/ 2769 }, 2770 2771 /* special segment options */ 2772 segment: { 2773 /**#@+ 2774 * @visprop 2775 */ 2776 2777 label: { 2778 position: 'top' 2779 } 2780 /**#@-*/ 2781 }, 2782 2783 semicircle: { 2784 /**#@+ 2785 * @visprop 2786 */ 2787 2788 /** 2789 * Attributes for center point of the semicircle. 2790 * 2791 * @type Point 2792 * @name Semicircle#midpoint 2793 */ 2794 midpoint: { 2795 visible: false, 2796 withLabel: false, 2797 fixed: false, 2798 name: '' 2799 } 2800 2801 /**#@-*/ 2802 }, 2803 2804 /* special slider options */ 2805 slider: { 2806 /**#@+ 2807 * @visprop 2808 */ 2809 2810 /** 2811 * The slider only returns integer multiples of this value, e.g. for discrete values set this property to <tt>1</tt>. For 2812 * continuous results set this to <tt>-1</tt>. 2813 * 2814 * @memberOf Slider.prototype 2815 * @name snapWidth 2816 * @type Number 2817 */ 2818 snapWidth: -1, // -1 = deactivated 2819 2820 /** 2821 * The precision of the slider value displayed in the optional text. 2822 * @memberOf Slider.prototype 2823 * @name precision 2824 * @type Number 2825 * @default 2 2826 */ 2827 precision: 2, 2828 2829 firstArrow: false, 2830 lastArrow: false, 2831 2832 /** 2833 * Show slider ticks. 2834 * 2835 * @type Boolean 2836 * @name Slider#withTicks 2837 * @default true 2838 */ 2839 withTicks: true, 2840 2841 /** 2842 * Show slider label. 2843 * 2844 * @type Boolean 2845 * @name Slider#withLabel 2846 * @default true 2847 */ 2848 withLabel: true, 2849 2850 layer: 9, 2851 showInfobox: false, 2852 name: '', 2853 visible: true, 2854 strokeColor: '#000000', 2855 highlightStrokeColor: '#888888', 2856 fillColor: '#ffffff', 2857 highlightFillColor: 'none', 2858 2859 /** 2860 * Size of slider point. 2861 * 2862 * @type Number 2863 * @name Slider#size 2864 * @default 6 2865 * @see Point#size 2866 */ 2867 size: 6, 2868 2869 /** 2870 * Attributes for first (left) helper point defining the slider position. 2871 * 2872 * @type Point 2873 * @name Slider#point1 2874 */ 2875 point1: { 2876 needsRegularUpdate: false, 2877 showInfobox: false, 2878 withLabel: false, 2879 visible: false, 2880 fixed: true, 2881 name: '' 2882 }, 2883 2884 /** 2885 * Attributes for second (right) helper point defining the slider position. 2886 * 2887 * @type Point 2888 * @name Slider#point2 2889 */ 2890 point2: { 2891 needsRegularUpdate: false, 2892 showInfobox: false, 2893 withLabel: false, 2894 visible: false, 2895 fixed: true, 2896 name: '' 2897 }, 2898 2899 /** 2900 * Attributes for the base line of the slider. 2901 * 2902 * @type Line 2903 * @name Slider#baseline 2904 */ 2905 baseline: { 2906 needsRegularUpdate: false, 2907 fixed: true, 2908 name: '', 2909 strokeWidth: 1, 2910 strokeColor: '#000000', 2911 highlightStrokeColor: '#888888' 2912 }, 2913 2914 /** 2915 * Attributes for the ticks of the base line of the slider. 2916 * 2917 * @type Ticks 2918 * @name Slider#ticks 2919 */ 2920 ticks: { 2921 needsRegularUpdate: false, 2922 fixed: true, 2923 drawLabels: false, 2924 drawZero: true, 2925 insertTicks: true, 2926 minorHeight: 4, // if <0: full width and height 2927 majorHeight: 5, // if <0: full width and height 2928 minorTicks: 0, 2929 defaultDistance: 1, 2930 strokeOpacity: 1, 2931 strokeWidth: 1, 2932 tickEndings: [0, 1], 2933 strokeColor: '#000000' 2934 }, 2935 2936 /** 2937 * Attributes for the highlighting line of the slider. 2938 * 2939 * @type Line 2940 * @name Slider#highline 2941 */ 2942 highline: { 2943 strokeWidth: 3, 2944 fixed: true, 2945 name: '', 2946 strokeColor: '#000000', 2947 highlightStrokeColor: '#888888' 2948 }, 2949 2950 /** 2951 * Attributes for the slider label. 2952 * 2953 * @type Label 2954 * @name Slider#label 2955 */ 2956 label: { 2957 strokeColor: '#000000' 2958 } 2959 2960 /**#@-*/ 2961 }, 2962 2963 /* special options for slope triangle */ 2964 slopetriangle: { 2965 /**#@+ 2966 * @visprop 2967 */ 2968 2969 fillColor: 'red', 2970 fillOpacity: 0.4, 2971 highlightFillColor: 'red', 2972 highlightFillOpacity: 0.3, 2973 2974 /** 2975 * Attributes for the gliding helper point. 2976 * 2977 * @type Point 2978 * @name Slopetriangle#glider 2979 */ 2980 glider: { 2981 fixed: true, 2982 visible: false, 2983 withLabel: false 2984 }, 2985 2986 /** 2987 * Attributes for the base line. 2988 * 2989 * @type Line 2990 * @name Slopetriangle#baseline 2991 */ 2992 baseline: { 2993 visible: false, 2994 withLabel: false, 2995 name: '' 2996 }, 2997 2998 /** 2999 * Attributes for the base point. 3000 * 3001 * @type Point 3002 * @name Slopetriangle#basepoint 3003 */ 3004 basepoint: { 3005 visible: false, 3006 withLabel: false, 3007 name: '' 3008 }, 3009 3010 /** 3011 * Attributes for the tangent. 3012 * The tangent is constructed by slop triangle if the construction 3013 * is based on a glider, solely. 3014 * 3015 * @type Line 3016 * @name Slopetriangle#tangent 3017 */ 3018 tangent: { 3019 visible: false, 3020 withLabel: false, 3021 name: '' 3022 }, 3023 3024 /** 3025 * Attributes for the top point. 3026 * 3027 * @type Point 3028 * @name Slopetriangle#toppoint 3029 */ 3030 toppoint: { 3031 visible: false, 3032 withLabel: false, 3033 name: '' 3034 }, 3035 3036 /** 3037 * Attributes for the slope triangle label. 3038 * 3039 * @type Label 3040 * @name Slopetriangle#label 3041 */ 3042 label: { 3043 visible: true 3044 } 3045 /**#@-*/ 3046 }, 3047 3048 /* special options for step functions */ 3049 stepfunction: { 3050 /**#@+ 3051 * @visprop 3052 */ 3053 3054 /**#@-*/ 3055 }, 3056 3057 /* special tape measure options */ 3058 tapemeasure: { 3059 /**#@+ 3060 * @visprop 3061 */ 3062 3063 strokeColor: '#000000', 3064 strokeWidth: 2, 3065 highlightStrokeColor: '#000000', 3066 3067 /** 3068 * Show tape measure ticks. 3069 * 3070 * @type Boolean 3071 * @name Tapemeasure#withTicks 3072 * @default true 3073 */ 3074 withTicks: true, 3075 3076 /** 3077 * Show tape measure label. 3078 * 3079 * @type Boolean 3080 * @name Tapemeasure#withLabel 3081 * @default true 3082 */ 3083 withLabel: true, 3084 3085 /** 3086 * The precision of the tape measure value displayed in the optional text. 3087 * @memberOf Tapemeasure.prototype 3088 * @name precision 3089 * @type Number 3090 * @default 2 3091 */ 3092 precision: 2, 3093 3094 /** 3095 * Attributes for first helper point defining the tape measure position. 3096 * 3097 * @type Point 3098 * @name Tapemeasure#point1 3099 */ 3100 point1: { 3101 strokeColor: '#000000', 3102 fillColor: '#ffffff', 3103 fillOpacity: 0.0, 3104 highlightFillOpacity: 0.1, 3105 size: 6, 3106 snapToPoints: true, 3107 attractorUnit: 'screen', 3108 attractorDistance: 20, 3109 showInfobox: false, 3110 withLabel: false, 3111 name: '' 3112 }, 3113 3114 /** 3115 * Attributes for second helper point defining the tape measure position. 3116 * 3117 * @type Point 3118 * @name Tapemeasure#point2 3119 */ 3120 point2: { 3121 strokeColor: '#000000', 3122 fillColor: '#ffffff', 3123 fillOpacity: 0.0, 3124 highlightFillOpacity: 0.1, 3125 size: 6, 3126 snapToPoints: true, 3127 attractorUnit: 'screen', 3128 attractorDistance: 20, 3129 showInfobox: false, 3130 withLabel: false, 3131 name: '' 3132 }, 3133 3134 /** 3135 * Attributes for the ticks of the tape measure. 3136 * 3137 * @type Ticks 3138 * @name Tapemeasure#ticks 3139 */ 3140 ticks: { 3141 drawLabels: false, 3142 drawZero: true, 3143 insertTicks: true, 3144 minorHeight: 8, 3145 majorHeight: 16, 3146 minorTicks: 4, 3147 tickEndings: [0, 1], 3148 defaultDistance: 0.1, 3149 strokeOpacity: 1, 3150 strokeWidth: 1, 3151 strokeColor: '#000000' 3152 }, 3153 3154 /** 3155 * Attributes for the tape measure label. 3156 * 3157 * @type Label 3158 * @name Tapemeasure#label 3159 */ 3160 label: { 3161 position: 'top' 3162 } 3163 /**#@-*/ 3164 }, 3165 3166 /* special text options */ 3167 text: { 3168 /**#@+ 3169 * @visprop 3170 */ 3171 3172 /** 3173 * The font size in pixels. 3174 * 3175 * @name fontSize 3176 * @memberOf Text.prototype 3177 * @default 12 3178 * @type Number 3179 */ 3180 fontSize: 12, 3181 3182 /** 3183 * Used to round texts given by a number. 3184 * 3185 * @name digits 3186 * @memberOf Text.prototype 3187 * @default 2 3188 * @type Number 3189 */ 3190 digits: 2, 3191 3192 /** 3193 * If set to true, the text is parsed and evaluated. 3194 * For labels parse==true results in converting names of the form k_a to subscripts. 3195 * If the text is given by string and parse==true, the string is parsed as 3196 * JessieCode expression. 3197 * 3198 * @name parse 3199 * @memberOf Text.prototype 3200 * @default true 3201 * @type Boolean 3202 */ 3203 parse: true, 3204 3205 /** 3206 * If set to true and caja's sanitizeHTML function can be found it 3207 * will be used to sanitize text output. 3208 * 3209 * @name useCaja 3210 * @memberOf Text.prototype 3211 * @default false 3212 * @type Boolean 3213 */ 3214 useCaja: false, 3215 3216 /** 3217 * If enabled, the text will be handled as label. Intended for internal use. 3218 * 3219 * @name isLabel 3220 * @memberOf Text.prototype 3221 * @default false 3222 * @type Boolean 3223 */ 3224 isLabel: false, 3225 3226 strokeColor: 'black', 3227 highlightStrokeColor: 'black', 3228 highlightStrokeOpacity: 0.666666, 3229 3230 /** 3231 * If true the input will be given to ASCIIMathML before rendering. 3232 * 3233 * @name useASCIIMathML 3234 * @memberOf Text.prototype 3235 * @default false 3236 * @type Boolean 3237 */ 3238 useASCIIMathML: false, 3239 3240 /** 3241 * If true MathJax will be used to render the input string. 3242 * 3243 * @name useMathJax 3244 * @memberOf Text.prototype 3245 * @default false 3246 * @type Boolean 3247 */ 3248 useMathJax: false, 3249 3250 /** 3251 * Determines the rendering method of the text. Possible values 3252 * include <tt>'html'</tt> and <tt>'internal</tt>. 3253 * 3254 * @name display 3255 * @memberOf Text.prototype 3256 * @default 'html' 3257 * @type String 3258 */ 3259 display: 'html', 3260 3261 /** 3262 * If true, the element is not placed into a foreignObject element. 3263 * Instead, the element is placed into a separate HTML div element "above" 3264 * the JSXGraph construction. 3265 * This is necessary to enable interaction. 3266 * The drawback is that a SVG export will not display this element. 3267 * 3268 * @type {Boolean} 3269 */ 3270 externalHTML: true, 3271 3272 /** 3273 * Anchor element {@link Point}, {@link Text} or {@link Image} of the text. If it exists, the coordinates of the text are relative 3274 * to this anchor element. 3275 * 3276 * @name anchor 3277 * @memberOf Text.prototype 3278 * @default null 3279 * @type Object 3280 */ 3281 anchor: null, 3282 3283 /** 3284 * The horizontal alignment of the text. Possible values include <tt>'left'</tt>, <tt>'middle'</tt>, and 3285 * <tt>'right'</tt>. 3286 * 3287 * @name anchorX 3288 * @memberOf Text.prototype 3289 * @default 'left' 3290 * @type String 3291 */ 3292 anchorX: 'left', 3293 3294 /** 3295 * The vertical alignment of the text. Possible values include <tt>'top'</tt>, <tt>'middle'</tt>, and 3296 * <tt>'bottom'</tt>. 3297 * 3298 * @name anchorY 3299 * @memberOf Text.prototype 3300 * @default 'middle' 3301 * @type String 3302 */ 3303 anchorY: 'middle', 3304 3305 /** 3306 * The precision of the slider value displayed in the optional text. 3307 * 3308 * @name cssClass 3309 * @memberOf Text.prototype 3310 * @type String 3311 */ 3312 cssClass: 'JXGtext', 3313 3314 /** 3315 * The precision of the slider value displayed in the optional text. 3316 * 3317 * @name highlightCssClass 3318 * @memberOf Text.prototype 3319 * @type String 3320 */ 3321 highlightCssClass: 'JXGtext', 3322 3323 /** 3324 * Sensitive area for dragging the text. 3325 * Possible values are 'all', or something else. 3326 * This may be extended to left, right, ... in the future. 3327 * 3328 * @name Text#dragArea 3329 * @type String 3330 * @default 'all' 3331 */ 3332 dragArea: 'all', 3333 3334 withLabel: false, 3335 3336 /** 3337 * Text rotation in degrees. 3338 * Works for non-zero values only in combination with display=='internal'. 3339 * 3340 * @name Text#rotate 3341 * @type Number 3342 * @default 0 3343 */ 3344 rotate: 0, 3345 3346 visible: true, 3347 3348 /** 3349 * Defines together with {@link Text#snapSizeY} the grid the text snaps on to. 3350 * The text will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 3351 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 3352 * of the default ticks of the default x axes of the board. 3353 * 3354 * @name snapSizeX 3355 * @memberOf Text.prototype 3356 * 3357 * @see JXG.Point#snapToGrid 3358 * @see Text#snapSizeY 3359 * @see JXG.Board#defaultAxes 3360 * @type Number 3361 * @default 1 3362 */ 3363 snapSizeX: 1, 3364 3365 /** 3366 * Defines together with {@link Text#snapSizeX} the grid the text snaps on to. 3367 * The text will only snap on integer multiples to snapSizeX in x and snapSizeY in y direction. 3368 * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks 3369 * of the default ticks of the default y axes of the board. 3370 * 3371 * @name snapSizeY 3372 * @memberOf Text.prototype 3373 * 3374 * @see JXG.Point#snapToGrid 3375 * @see Text#snapSizeX 3376 * @see JXG.Board#defaultAxes 3377 * @type Number 3378 * @default 1 3379 */ 3380 snapSizeY: 1, 3381 3382 /** 3383 * List of attractor elements. If the distance of the text is less than 3384 * attractorDistance the text is made to glider of this element. 3385 * 3386 * @name attractors 3387 * @memberOf Text.prototype 3388 * @type array 3389 * @default empty 3390 */ 3391 attractors: [] 3392 3393 /**#@-*/ 3394 }, 3395 3396 /* special options for trace curves */ 3397 tracecurve: { 3398 /**#@+ 3399 * @visprop 3400 */ 3401 strokeColor: '#000000', 3402 fillColor: 'none', 3403 3404 /** 3405 * The number of evaluated data points. 3406 * @memberOf Tracecurve.prototype 3407 * @default 100 3408 * @name numberPoints 3409 * @type Number 3410 */ 3411 numberPoints: 100 3412 3413 /**#@-*/ 3414 }, 3415 3416 /*special turtle options */ 3417 turtle: { 3418 /**#@+ 3419 * @visprop 3420 */ 3421 3422 strokeWidth: 1, 3423 fillColor: 'none', 3424 strokeColor: '#000000', 3425 3426 /** 3427 * Attributes for the turtle arrow. 3428 * 3429 * @type Curve 3430 * @name Turtle#arrow 3431 */ 3432 arrow: { 3433 strokeWidth: 2, 3434 withLabel: false, 3435 strokeColor: '#ff0000' 3436 } 3437 /**#@-*/ 3438 }, 3439 3440 /** 3441 * Abbreviations of properties. Setting the shortcut means setting abbreviated properties 3442 * to the same value. 3443 * It is used in {@link JXG.GeometryElement#setAttribute} and in 3444 * the constructor {@link JXG.GeometryElement}. 3445 * Attention: In Options.js abbreviations are not allowed. 3446 */ 3447 shortcuts: { 3448 color: ['strokeColor', 'fillColor'], 3449 opacity: ['strokeOpacity', 'fillOpacity'], 3450 highlightColor: ['highlightStrokeColor', 'highlightFillColor'], 3451 highlightOpacity: ['highlightStrokeOpacity', 'highlightFillOpacity'], 3452 strokeWidth: ['strokeWidth', 'highlightStrokeWidth'] 3453 } 3454 3455 }; 3456 3457 /** 3458 * Holds all possible properties and the according validators for geometry elements. A validator is either a function 3459 * which takes one parameter and returns true, if the value is valid for the property, or it is false if no validator 3460 * is required. 3461 */ 3462 JXG.Validator = (function () { 3463 var i, 3464 validatePixel = function (v) { 3465 return (/^[0-9]+px$/).test(v); 3466 }, 3467 validateDisplay = function (v) { 3468 return (v === 'html' || v === 'internal'); 3469 }, 3470 validateColor = function (v) { 3471 // for now this should do it... 3472 return Type.isString(v); 3473 }, 3474 validatePointFace = function (v) { 3475 return Type.exists(JXG.normalizePointFace(v)); 3476 }, 3477 validateInteger = function (v) { 3478 return (Math.abs(v - Math.round(v)) < Mat.eps); 3479 }, 3480 validatePositiveInteger = function (v) { 3481 return validateInteger(v) && v > 0; 3482 }, 3483 validateScreenCoords = function (v) { 3484 return v.length >= 2 && validateInteger(v[0]) && validateInteger(v[1]); 3485 }, 3486 validateRenderer = function (v) { 3487 return (v === 'vml' || v === 'svg' || v === 'canvas' || v === 'no'); 3488 }, 3489 validatePositive = function (v) { 3490 return v > 0; 3491 }, 3492 validateNotNegative = function (v) { 3493 return v >= 0; 3494 }, 3495 v = {}, 3496 validators = { 3497 attractorDistance: validateNotNegative, 3498 color: validateColor, 3499 defaultDistance: Type.isNumber, 3500 display: validateDisplay, 3501 doAdvancedPlot: false, 3502 draft: false, 3503 drawLabels: false, 3504 drawZero: false, 3505 face: validatePointFace, 3506 factor: Type.isNumber, 3507 fillColor: validateColor, 3508 fillOpacity: Type.isNumber, 3509 firstArrow: false, 3510 fontSize: validateInteger, 3511 dash: validateInteger, 3512 gridX: Type.isNumber, 3513 gridY: Type.isNumber, 3514 hasGrid: false, 3515 highlightFillColor: validateColor, 3516 highlightFillOpacity: Type.isNumber, 3517 highlightStrokeColor: validateColor, 3518 highlightStrokeOpacity: Type.isNumber, 3519 insertTicks: false, 3520 //: validateScreenCoords, 3521 lastArrow: false, 3522 majorHeight: validateInteger, 3523 minorHeight: validateInteger, 3524 minorTicks: validateNotNegative, 3525 minTicksDistance: validatePositiveInteger, 3526 numberPointsHigh: validatePositiveInteger, 3527 numberPointsLow: validatePositiveInteger, 3528 opacity: Type.isNumber, 3529 radius: Type.isNumber, 3530 RDPsmoothing: false, 3531 renderer: validateRenderer, 3532 right: validatePixel, 3533 showCopyright: false, 3534 showInfobox: false, 3535 showNavigation: false, 3536 size: validateInteger, 3537 snapSizeX: validatePositive, 3538 snapSizeY: validatePositive, 3539 snapWidth: Type.isNumber, 3540 snapToGrid: false, 3541 snatchDistance: validateNotNegative, 3542 straightFirst: false, 3543 straightLast: false, 3544 stretch: false, 3545 strokeColor: validateColor, 3546 strokeOpacity: Type.isNumber, 3547 strokeWidth: validateInteger, 3548 takeFirst: false, 3549 takeSizeFromFile: false, 3550 to10: false, 3551 toOrigin: false, 3552 translateTo10: false, 3553 translateToOrigin: false, 3554 useASCIIMathML: false, 3555 useDirection: false, 3556 useMathJax: false, 3557 withLabel: false, 3558 withTicks: false, 3559 zoom: false 3560 }; 3561 3562 // this seems like a redundant step but it makes sure that 3563 // all properties in the validator object have lower case names 3564 // and the validator object is easier to read. 3565 for (i in validators) { 3566 if (validators.hasOwnProperty(i)) { 3567 v[i.toLowerCase()] = validators[i]; 3568 } 3569 } 3570 3571 return v; 3572 }()); 3573 3574 /** 3575 * All point faces can be defined with more than one name, e.g. a cross faced point can be given 3576 * by face equal to 'cross' or equal to 'x'. This method maps all possible values to fixed ones to 3577 * simplify if- and switch-clauses regarding point faces. The translation table is as follows: 3578 * <table> 3579 * <tr><th>Input</th><th>Output</th></tr> 3580 * <tr><td>cross, x</td><td>x</td></tr> 3581 * <tr><td>circle, o</td><td>o</td></tr> 3582 * <tr><td>square, []</td><td>[]</td></tr> 3583 * <tr><td>plus, +</td><td>+</td></tr> 3584 * <tr><td>diamond, <></td><td><></td></tr> 3585 * <tr><td>triangleup, a, ^</td><td>A</td></tr> 3586 * <tr><td>triangledown, v</td><td>v</td></tr> 3587 * <tr><td>triangleleft, <</td><td><</td></tr> 3588 * <tr><td>triangleright, ></td><td>></td></tr> 3589 * </table> 3590 * @param {String} s A string which should determine a valid point face. 3591 * @returns {String} Returns a normalized string or undefined if the given string is not a valid 3592 * point face. 3593 */ 3594 JXG.normalizePointFace = function (s) { 3595 var map = { 3596 cross: 'x', 3597 x: 'x', 3598 circle: 'o', 3599 o: 'o', 3600 square: '[]', 3601 '[]': '[]', 3602 plus: '+', 3603 '+': '+', 3604 diamond: '<>', 3605 '<>': '<>', 3606 triangleup: '^', 3607 a: '^', 3608 '^': '^', 3609 triangledown: 'v', 3610 v: 'v', 3611 triangleleft: '<', 3612 '<': '<', 3613 triangleright: '>', 3614 '>': '>' 3615 }; 3616 3617 return map[s]; 3618 }; 3619 3620 3621 /** 3622 * Apply the options stored in this object to all objects on the given board. 3623 * @param {JXG.Board} board The board to which objects the options will be applied. 3624 */ 3625 JXG.useStandardOptions = function (board) { 3626 var el, t, p, copyProps, 3627 o = JXG.Options, 3628 boardHadGrid = board.hasGrid; 3629 3630 board.options.grid.hasGrid = o.grid.hasGrid; 3631 board.options.grid.gridX = o.grid.gridX; 3632 board.options.grid.gridY = o.grid.gridY; 3633 board.options.grid.gridColor = o.grid.gridColor; 3634 board.options.grid.gridOpacity = o.grid.gridOpacity; 3635 board.options.grid.gridDash = o.grid.gridDash; 3636 board.options.grid.snapToGrid = o.grid.snapToGrid; 3637 board.options.grid.snapSizeX = o.grid.SnapSizeX; 3638 board.options.grid.snapSizeY = o.grid.SnapSizeY; 3639 board.takeSizeFromFile = o.takeSizeFromFile; 3640 3641 copyProps = function (p, o) { 3642 p.visProp.fillcolor = o.fillColor; 3643 p.visProp.highlightfillcolor = o.highlightFillColor; 3644 p.visProp.strokecolor = o.strokeColor; 3645 p.visProp.highlightstrokecolor = o.highlightStrokeColor; 3646 }; 3647 3648 for (el in board.objects) { 3649 if (board.objects.hasOwnProperty(el)) { 3650 p = board.objects[el]; 3651 if (p.elementClass === Const.OBJECT_CLASS_POINT) { 3652 copyProps(p, o.point); 3653 } else if (p.elementClass === Const.OBJECT_CLASS_LINE) { 3654 copyProps(p, o.line); 3655 3656 for (t = 0; t < p.ticks.length; t++) { 3657 p.ticks[t].majorTicks = o.line.ticks.majorTicks; 3658 p.ticks[t].minTicksDistance = o.line.ticks.minTicksDistance; 3659 p.ticks[t].visProp.minorheight = o.line.ticks.minorHeight; 3660 p.ticks[t].visProp.majorheight = o.line.ticks.majorHeight; 3661 } 3662 } else if (p.elementClass === Const.OBJECT_CLASS_CIRCLE) { 3663 copyProps(p, o.circle); 3664 } else if (p.type === Const.OBJECT_TYPE_ANGLE) { 3665 copyProps(p, o.angle); 3666 } else if (p.type === Const.OBJECT_TYPE_ARC) { 3667 copyProps(p, o.arc); 3668 } else if (p.type === Const.OBJECT_TYPE_POLYGON) { 3669 copyProps(p, o.polygon); 3670 } else if (p.type === Const.OBJECT_TYPE_CONIC) { 3671 copyProps(p, o.conic); 3672 } else if (p.type === Const.OBJECT_TYPE_CURVE) { 3673 copyProps(p, o.curve); 3674 } else if (p.type === Const.OBJECT_TYPE_SECTOR) { 3675 p.arc.visProp.fillcolor = o.sector.fillColor; 3676 p.arc.visProp.highlightfillcolor = o.sector.highlightFillColor; 3677 p.arc.visProp.fillopacity = o.sector.fillOpacity; 3678 p.arc.visProp.highlightfillopacity = o.sector.highlightFillOpacity; 3679 } 3680 } 3681 } 3682 3683 board.fullUpdate(); 3684 if (boardHadGrid && !board.hasGrid) { 3685 board.removeGrids(board); 3686 } else if (!boardHadGrid && board.hasGrid) { 3687 board.create('grid', []); 3688 } 3689 }; 3690 3691 /** 3692 * Converts all color values to greyscale and calls useStandardOption to put them onto the board. 3693 * @param {JXG.Board} board The board to which objects the options will be applied. 3694 * @see #useStandardOptions 3695 */ 3696 JXG.useBlackWhiteOptions = function (board) { 3697 var o = JXG.Options; 3698 o.point.fillColor = Color.rgb2bw(o.point.fillColor); 3699 o.point.highlightFillColor = Color.rgb2bw(o.point.highlightFillColor); 3700 o.point.strokeColor = Color.rgb2bw(o.point.strokeColor); 3701 o.point.highlightStrokeColor = Color.rgb2bw(o.point.highlightStrokeColor); 3702 3703 o.line.fillColor = Color.rgb2bw(o.line.fillColor); 3704 o.line.highlightFillColor = Color.rgb2bw(o.line.highlightFillColor); 3705 o.line.strokeColor = Color.rgb2bw(o.line.strokeColor); 3706 o.line.highlightStrokeColor = Color.rgb2bw(o.line.highlightStrokeColor); 3707 3708 o.circle.fillColor = Color.rgb2bw(o.circle.fillColor); 3709 o.circle.highlightFillColor = Color.rgb2bw(o.circle.highlightFillColor); 3710 o.circle.strokeColor = Color.rgb2bw(o.circle.strokeColor); 3711 o.circle.highlightStrokeColor = Color.rgb2bw(o.circle.highlightStrokeColor); 3712 3713 o.arc.fillColor = Color.rgb2bw(o.arc.fillColor); 3714 o.arc.highlightFillColor = Color.rgb2bw(o.arc.highlightFillColor); 3715 o.arc.strokeColor = Color.rgb2bw(o.arc.strokeColor); 3716 o.arc.highlightStrokeColor = Color.rgb2bw(o.arc.highlightStrokeColor); 3717 3718 o.polygon.fillColor = Color.rgb2bw(o.polygon.fillColor); 3719 o.polygon.highlightFillColor = Color.rgb2bw(o.polygon.highlightFillColor); 3720 3721 o.sector.fillColor = Color.rgb2bw(o.sector.fillColor); 3722 o.sector.highlightFillColor = Color.rgb2bw(o.sector.highlightFillColor); 3723 3724 o.curve.strokeColor = Color.rgb2bw(o.curve.strokeColor); 3725 o.grid.gridColor = Color.rgb2bw(o.grid.gridColor); 3726 3727 JXG.useStandardOptions(board); 3728 }; 3729 3730 // needs to be exported 3731 JXG.Options.normalizePointFace = JXG.normalizePointFace; 3732 3733 return JXG.Options; 3734 }); 3735