1 /*
  2     Copyright 2008-2013
  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      */
 54     JXG.Options = {
 55         jc: {
 56             enabled: true,
 57             compile: true
 58         },
 59 
 60         /* Options that are used directly within the board class */
 61         board: {
 62             boundingBox: [-5, 5, 5, -5],
 63             zoomFactor: 1,
 64             zoomX: 1,
 65             zoomY: 1,
 66             showCopyright: true,
 67             axis: false,
 68             showNavigation: true,
 69             showReload: false,
 70             keepAspectRatio: false,
 71             // if true the first element with hasPoint==true is taken.
 72             takeFirst: false,
 73             // If true, the construction - when read from a file or string - the size of the div can be changed.
 74             takeSizeFromFile: false,
 75             renderer: 'svg',
 76             animationDelay: 35,
 77             registerEvents: true,
 78             minimizeReflow: 'svg',
 79             /**
 80              * A number that will be added to the absolute position of the board used in mouse coordinate
 81              * calculations in {@link #getCoordsTopLeftCorner}.
 82              * @type {number}
 83              */
 84             offsetX: 0,
 85             /**
 86              * A number that will be added to the absolute position of the board used in mouse coordinate
 87              * calculations in {@link #getCoordsTopLeftCorner}.
 88              * @type {number}
 89              */
 90             offsetY: 0,
 91             zoom: {
 92                 factorX: 1.25,
 93                 factorY: 1.25,
 94                 wheel: false,
 95                 needshift: false,
 96                 eps: 0.1
 97             },
 98             pan: {
 99                 needShift: true,
100                 needTwoFingers: true,
101                 enabled: true
102             }
103         },
104 
105         /* navbar options */
106         navbar: {
107             strokeColor: '#aaaaaa',
108             fillColor: '#f5f5f5',
109             padding: '2px',
110             position: 'absolute',
111             fontSize: '10px',
112             cursor: 'pointer',
113             zIndex: '100',
114             right: '5px',
115             bottom: '5px'
116         },
117 
118         /**
119          * Generic options
120          */
121 
122         /* geometry element options */
123         elements: {
124             // the following tag is a meta tag: http://code.google.com/p/jsdoc-toolkit/wiki/MetaTags
125 
126             /**#@+
127              * @visprop
128              */
129 
130             /**
131              * The stroke color of the given geometry element.
132              * @type String
133              * @name JXG.GeometryElement#strokeColor
134              * @see JXG.GeometryElement#highlightStrokeColor
135              * @see JXG.GeometryElement#strokeWidth
136              * @see JXG.GeometryElement#strokeOpacity
137              * @see JXG.GeometryElement#highlightStrokeOpacity
138              * @default {@link JXG.Options.elements.color#strokeColor}
139              */
140             strokeColor: '#0000ff',
141 
142             /**
143              * The stroke color of the given geometry element when the user moves the mouse over it.
144              * @type String
145              * @name JXG.GeometryElement#highlightStrokeColor
146              * @see JXG.GeometryElement#strokeColor
147              * @see JXG.GeometryElement#strokeWidth
148              * @see JXG.GeometryElement#strokeOpacity
149              * @see JXG.GeometryElement#highlightStrokeOpacity
150              * @default {@link JXG.Options.elements.color#highlightStrokeColor}
151              */
152             highlightStrokeColor: '#C3D9FF',
153 
154             /**
155              * The fill color of this geometry element.
156              * @type String
157              * @name JXG.GeometryElement#fillColor
158              * @see JXG.GeometryElement#highlightFillColor
159              * @see JXG.GeometryElement#fillOpacity
160              * @see JXG.GeometryElement#highlightFillOpacity
161              * @default {@link JXG.Options.elements.color#fillColor}
162              */
163             fillColor: 'red',
164 
165             /**
166              * The fill color of the given geometry element when the mouse is pointed over it.
167              * @type String
168              * @name JXG.GeometryElement#highlightFillColor
169              * @see JXG.GeometryElement#fillColor
170              * @see JXG.GeometryElement#fillOpacity
171              * @see JXG.GeometryElement#highlightFillOpacity
172              * @default {@link JXG.Options.elements.color#highlightFillColor}
173              */
174             highlightFillColor: 'none',
175 
176             /**
177              * Opacity for element's stroke color.
178              * @type number
179              * @name JXG.GeometryElement#strokeOpacity
180              * @see JXG.GeometryElement#strokeColor
181              * @see JXG.GeometryElement#highlightStrokeColor
182              * @see JXG.GeometryElement#strokeWidth
183              * @see JXG.GeometryElement#highlightStrokeOpacity
184              * @default {@link JXG.Options.elements#strokeOpacity}
185              */
186             strokeOpacity: 1,
187 
188             /**
189              * Opacity for stroke color when the object is highlighted.
190              * @type number
191              * @name JXG.GeometryElement#highlightStrokeOpacity
192              * @see JXG.GeometryElement#strokeColor
193              * @see JXG.GeometryElement#highlightStrokeColor
194              * @see JXG.GeometryElement#strokeWidth
195              * @see JXG.GeometryElement#strokeOpacity
196              * @default {@link JXG.Options.elements#highlightStrokeOpacity}
197              */
198             highlightStrokeOpacity: 1,
199 
200             /**
201              * Opacity for fill color.
202              * @type number
203              * @name JXG.GeometryElement#fillOpacity
204              * @see JXG.GeometryElement#fillColor
205              * @see JXG.GeometryElement#highlightFillColor
206              * @see JXG.GeometryElement#highlightFillOpacity
207              * @default {@link JXG.Options.elements.color#fillOpacity}
208              */
209             fillOpacity: 1,
210 
211             /**
212              * Opacity for fill color when the object is highlighted.
213              * @type number
214              * @name JXG.GeometryElement#highlightFillOpacity
215              * @see JXG.GeometryElement#fillColor
216              * @see JXG.GeometryElement#highlightFillColor
217              * @see JXG.GeometryElement#fillOpacity
218              * @default {@link JXG.Options.elements.color#highlightFillOpacity}
219              */
220             highlightFillOpacity: 1,
221 
222             /**
223              * Width of the element's stroke.
224              * @type number
225              * @name JXG.GeometryElement#strokeWidth
226              * @see JXG.GeometryElement#strokeColor
227              * @see JXG.GeometryElement#highlightStrokeColor
228              * @see JXG.GeometryElement#strokeOpacity
229              * @see JXG.GeometryElement#highlightStrokeOpacity
230              * @default {@link JXG.Options.elements#strokeWidth}
231              */
232             strokeWidth: 2,
233 
234             /**
235              * Width of the element's stroke when the mouse is pointed over it.
236              * @type number
237              * @name JXG.GeometryElement#highlightStrokeWidth
238              * @see JXG.GeometryElement#strokeColor
239              * @see JXG.GeometryElement#highlightStrokeColor
240              * @see JXG.GeometryElement#strokeOpacity
241              * @see JXG.GeometryElement#highlightStrokeOpacity
242              * @see JXG.GeometryElement#highlightFillColor
243              * @default {@link JXG.Options.elements#strokeWidth}
244              */
245             highlightStrokeWidth: 2,
246 
247 
248             /**
249              * If true the element is fixed and can not be dragged around. The element
250              * will be repositioned on zoom and moveOrigin events.
251              * @type Boolean
252              * @default false
253              * @name JXG.GeometryElement#fixed
254              */
255             fixed: false,
256 
257             /**
258              * If true the element is fixed and can not be dragged around. The element
259              * will even stay at its position on zoom and moveOrigin events.
260              * Only free elements like points, texts, curves can be frozen.
261              * @type Boolean
262              * @default false
263              * @name JXG.GeometryElement#frozen
264              */
265             frozen: false,
266 
267             /**
268              * If true a label will display the element's name.
269              * @type Boolean
270              * @default false
271              * @name JXG.GeometryElement#withLabel
272              */
273             withLabel: false,
274 
275             /**
276              * If false the element won't be visible on the board, otherwise it is shown.
277              * @type boolean
278              * @name JXG.GeometryElement#visible
279              * @see JXG.GeometryElement#hideElement
280              * @see JXG.GeometryElement#showElement
281              * @default true
282              */
283             visible: true,
284 
285             /**
286              * A private element will be inaccessible in certain environments, e.g. a graphical user interface.
287              * @default false
288              */
289             priv: false,
290 
291             /**
292              * Display layer which will contain the element.
293              * @see JXG.Options#layer
294              * @default See {@link JXG.Options#layer}
295              */
296             layer: 0,
297 
298 
299             /**
300              * Determines the elements border-style.
301              * Possible values are:
302              * <ul><li>0 for a solid line</li>
303              * <li>1 for a dotted line</li>
304              * <li>2 for a line with small dashes</li>
305 
306 
307              * <li>3 for a line with medium dashes</li>
308              * <li>4 for a line with big dashes</li>
309              * <li>5 for a line with alternating medium and big dashes and large gaps</li>
310              * <li>6 for a line with alternating medium and big dashes and small gaps</li></ul>
311              * @type Number
312              * @name JXG.GeometryElement#dash
313              * @default 0
314              */
315             dash: 0,
316 
317             /**
318              * If true the element will get a shadow.
319              * @type boolean
320              * @name JXG.GeometryElement#shadow
321              * @default false
322              */
323             shadow: false,
324 
325             /**
326              * If true the element will be traced, i.e. on every movement the element will be copied
327              * to the background. Use {@link JXG.GeometryElement#clearTrace} to delete the trace elements.
328              * @see JXG.GeometryElement#clearTrace
329              * @see JXG.GeometryElement#traces
330              * @see JXG.GeometryElement#numTraces
331              * @type Boolean
332              * @default false
333              * @name JXG.GeometryElement#trace
334              */
335             trace: false,
336 
337             /**
338              * Extra visual properties for traces of an element
339              * @type Object
340              * @see JXG.GeometryElement#trace
341              * @name JXG.GeometryElement#traceAttributes
342              */
343             traceAttributes: {},
344 
345             /**
346              *
347              * @type Boolean
348              * @default true
349              * @name JXG.GeometryElement#highlight
350              */
351             highlight: true,
352 
353             /**
354              * If this is set to true, the element is updated in every update
355              * call of the board. If set to false, the element is updated only after
356              * zoom events or more generally, when the bounding box has been changed.
357              * Examples for the latter behaviour should be axes.
358              * @type Boolean
359              * @default true
360              * @see JXG.GeometryElement#needsRegularUpdate
361              * @name JXG.GeometryElement#needsRegularUpdate
362              */
363             needsRegularUpdate: true,
364 
365             /**
366              * Snaps the element or its parents to the grid. Currently only relevant for points, circles,
367              * and lines. Points are snapped to grid directly, on circles and lines it's only the parent
368              * points that are snapped
369              * @type Boolean
370              * @default false
371              * @name JXG.GeometryElement#snapToGrid
372              */
373             snapToGrid: false,
374 
375             /**
376              * Determines whether two-finger manipulation of this object may change its size.
377              * If set to false, the object is only rotated and translated.
378              * @type Boolean
379              * @default true
380              * @name JXG.GeometryElement#scalable
381              */
382             scalable: true,
383 
384             /*draft options */
385             draft: {
386                 /**
387                  * If true the element will be drawn in grey scale colors to visualize that it's only a draft.
388                  * @type boolean
389                  * @name JXG.GeometryElement#draft
390                  * @default {@link JXG.Options.elements.draft#draft}
391                  */
392                 draft: false,
393                 strokeColor: '#565656',
394                 fillColor: '#565656',
395                 strokeOpacity: 0.8,
396                 fillOpacity: 0.8,
397                 strokeWidth: 1
398             },
399 
400             /**
401              * @private
402              * By default, an element is not a label. Do not change this.
403              */
404             isLabel: false
405             // close the meta tag
406             /**#@-*/
407         },
408 
409         ticks: {
410             /**#@+
411              * @visprop
412              */
413 
414             /**
415              * A function that expects two {@link JXG.Coords}, the first one representing the coordinates of the
416              * tick that is to be labeled, the second one the coordinates of the center (the tick with position 0).
417              * @type function
418              * @name JXG.Ticks#generateLabelValue
419              */
420             generateLabelValue: null,
421 
422             /**
423              * Draw labels yes/no
424              * @type Boolean
425              * @name JXG.Ticks#drawLabels
426              * @default false
427              */
428             drawLabels: false,
429             label: {},
430 
431             /**
432              * Determine the position of the tick with value 0. 'left' means point1 of the line, 'right' means point2,
433              * and 'middle' is equivalent to the midpoint of the defining points.
434              * @type String
435              * @name JXG.Ticks#anchor
436              * @default 'left'
437              */
438             anchor: 'left',
439 
440             /**
441              * Draw the zero tick, that lies at line.point1?
442              * @type Boolean
443              * @name JXG.Ticks#drawZero
444              * @default false
445              */
446             drawZero: false,
447 
448             /**
449              * If the distance between two ticks is too big we could insert new ticks. If insertTicks
450              * is <tt>true</tt>, we'll do so, otherwise we leave the distance as is.
451              * This option is ignored if equidistant is false.
452              * @type Boolean
453              * @name JXG.Ticks#insertTicks
454              * @see JXG.Ticks#equidistant
455              * @see JXG.Ticks#maxTicksDistance
456              * @default false
457              */
458             insertTicks: false,
459             minTicksDistance: 50,
460 
461             /**
462              * Total height of a minor tick. If negative the full height of the board is taken.
463              * @type Number
464              * @name JXG.Ticks#minorHeight
465              */
466             minorHeight: 4,
467 
468             /**
469              * Total height of a major tick. If negative the full height of the board is taken.
470              * @type Number
471              * @name JXG.Ticks#majorHeight
472              */
473             majorHeight: 10,
474 
475             /**
476              * Decides in which direction finite ticks are visible. Possible values are 0=false or 1=true.
477              * In case of [0,1] the tick is only visible to the right of the line. In case of
478              * [1,0] the tick is only visible to the left of the line.
479              * @type Array
480              * @name JXG.Ticks#tickEndings
481              */
482             tickEndings: [1, 1],
483 
484             /**
485              * The number of minor ticks between two major ticks.
486              * @type Number
487              * @name JXG.Ticks#minorTicks
488              */
489             minorTicks: 4,
490 
491             /**
492              * Scale the ticks but not the tick labels.
493              * @type Number
494              * @default 1
495              * @name JXG.Ticks#scale
496              * @see JXG.Ticks#scaleSymbol
497              */
498             scale: 1,
499 
500             /**
501              * A string that is appended to every tick, used to represent the scale
502              * factor given in {@link JXG.Ticks#scaleSymbol}.
503              * @type String
504              * @default ''
505              * @name JXG.Ticks#scaleSymbol
506              * @see JXG.Ticks#scale
507              */
508             scaleSymbol: '',
509 
510             /**
511              * User defined labels for special ticks. Instead of the i-th tick's position, the i-th string stored in this array
512              * is shown. If the number of strings in this array is less than the number of special ticks, the tick's position is
513              * shown as a fallback.
514              * @type Array
515              * @name JXG.Ticks#labels
516              * @default []
517              */
518             labels: [],
519 
520             /**
521              * The maximum number of characters a tick label can use.
522              * @type Number
523              * @name JXG.Ticks#maxLabelLength
524              * @see JXG.Ticks#precision
525              * @default 3
526              */
527             maxLabelLength: 5,
528 
529             /**
530              * If a label exceeds {@link JXG.Ticks#maxLabelLength} this determines the precision used to shorten the tick label.
531              * @type Number
532              * @name JXG.Ticks#precision
533              * @see JXG.Ticks#maxLabelLength
534              * @default 3
535              */
536             precision: 3,
537 
538             /**
539              * The default distance between two ticks. Please be aware that this value does not have
540              * to be used if {@link JXG.Ticks#insertTicks} is set to true.
541              * @type Boolean
542              * @name JXG.Ticks#ticksDistance
543              * @see JXG.Ticks#equidistant
544              * @see JXG.Ticks#insertTicks
545              * @default 1
546              */
547             ticksDistance: 1,
548             strokeOpacity: 1,
549             strokeWidth: 1,
550             strokeColor: 'black',
551             highlightStrokeColor: '#888888'
552             // close the meta tag
553             /**#@-*/
554         },
555 
556         hatch: {
557             drawLabels: false,
558             drawZero: true,
559             majorHeight: 20,
560             anchor: 'middle',
561             strokeWidth: 2,
562             strokeColor: 'blue',
563             ticksDistance: 0.2
564         },
565 
566         /* precision options */
567         precision: {
568             touch: 30,
569             touchMax: 100,
570             mouse: 4,
571             epsilon: 0.0001,
572             hasPoint: 4
573         },
574 
575         /* Default ordering of the layers */
576         layer: {
577             numlayers: 20, // only important in SVG
578             text: 9,
579             point: 9,
580             glider: 9,
581             arc: 8,
582             line: 7,
583             circle: 6,
584             curve: 5,
585             turtle: 5,
586             polygon: 3,
587             sector: 3,
588             angle: 3,
589             integral: 3,
590             axis: 2,
591             grid: 1,
592             image: 0,
593             trace: 0
594         },
595 
596         /**
597          * element type specific options
598          */
599         /* special angle options */
600         angle: {
601             withLabel: true,
602 
603             /**
604              * Radius of the sector, displaying the angle.
605              * @type Number
606              * @default 0.5
607              * @name Angle#radius
608              * @visprop
609              */
610             radius: 0.5,
611 
612             /**
613              * Display type of the angle field. Possible values are
614              * 'sector' or 'sectordot' or 'square' or 'none'.
615              * @type String
616              * @default sector
617              * @name Angle#type
618              * @visprop
619              */
620             type: 'sector',
621 
622             /**
623              * Display type of the angle field in case of a right angle. Possible values are
624              * 'sector' or 'sectordot' or 'square' or 'none'.
625              * @type String
626              * @default square
627              * @name Angle#orthoType
628              * @see Angle#orthoSensitivity
629              * @visprop
630              */
631             orthoType: 'square',
632 
633             /**
634              * Sensitivity (in degrees) to declare an angle as right angle.
635              * If the angle measure is inside this distance from a rigth angle, the orthoType
636              * of the angle is used for display.
637              * @type Number
638              * @default 1.0
639              * @name Angle#orthoSensitivity
640              * @see Angle#orthoType
641              * @visprop
642              */
643             orthoSensitivity: 1.0,
644             fillColor: '#FF7F00',
645             highlightFillColor: '#FF7F00',
646             strokeColor: '#FF7F00',
647             fillOpacity: 0.3,
648             highlightFillOpacity: 0.3,
649 
650             /**
651              * @deprecated
652              */
653             radiuspoint: {
654                 withLabel: false,
655                 visible: false,
656                 name: ''
657             },
658             /**
659              * @deprecated
660              */
661             pointsquare: {
662                 withLabel: false,
663                 visible: false,
664                 name: ''
665             },
666 
667             dot: {
668                 visible: false,
669                 strokeColor: 'none',
670                 fillColor: 'black',
671                 size: 2,
672                 face: 'o',
673                 withLabel: false,
674                 name: ''
675             },
676             label: {
677                 position: 'top',
678                 offset: [0, 0],
679                 strokeColor: '#0000FF'
680             }
681         },
682 
683         /* special arc options */
684         arc: {
685             label: {},
686             firstArrow: false,
687             lastArrow: false,
688             fillColor: 'none',
689             highlightFillColor: 'none',
690             strokeColor: '#0000ff',
691             highlightStrokeColor: '#C3D9FF',
692             useDirection: false
693         },
694 
695         /* special axis options */
696         axis: {
697             name: '',                            // By default, do not generate names for axes.
698             needsRegularUpdate: false,         // Axes only updated after zooming and moving of the origin.
699             strokeWidth: 1,
700             strokeColor: '#666666',
701             highlightStrokeWidth: 1,
702             highlightStrokeColor: '#888888',
703             withTicks: true,
704             straightFirst: true,
705             straightLast: true,
706             lastArrow: true,
707             withLabel: false,
708             scalable: false,
709             /* line ticks options */
710             ticks: {
711                 label: {
712                     offset: [4, -12 + 3],     // This seems to be a good offset for 12 point fonts
713                     parse: false
714                 },
715                 needsRegularUpdate: false,
716                 strokeWidth: 1,
717                 strokeColor: '#666666',
718                 highlightStrokeColor: '#888888',
719                 drawLabels: true,
720                 drawZero: false,
721                 insertTicks: true,
722                 minTicksDistance: 10,
723                 minorHeight: 10,          // if <0: full width and height
724                 majorHeight: -1,          // if <0: full width and height
725                 tickEndings: [0, 1],
726                 minorTicks: 4,
727                 ticksDistance: 1,         // TODO doc
728                 strokeOpacity: 0.25
729             },
730             point1: {                  // Default values for point1 if created by line
731                 needsRegularUpdate: false
732             },
733             point2: {                  // Default values for point2 if created by line
734                 needsRegularUpdate: false
735             },
736             label: {
737                 position: 'lft',
738                 offset: [10, -20]
739             }
740         },
741 
742         /* special options for bisector of 3 points */
743         bisector: {
744             strokeColor: '#000000', // Bisector line
745             point: {               // Bisector point
746                 visible: false,
747                 fixed: false,
748                 withLabel: false,
749                 name: ''
750             }
751         },
752 
753         /* special options for the 2 bisectors of 2 lines */
754         bisectorlines: {
755             line1: {               //
756                 strokeColor: 'black'
757             },
758             line2: {               //
759                 strokeColor: 'black'
760             }
761         },
762 
763         /* special chart options */
764         chart: {
765             chartStyle: 'line',
766             colors: ['#B02B2C', '#3F4C6B', '#C79810', '#D15600', '#FFFF88', '#C3D9FF', '#4096EE', '#008C00'],
767             highlightcolors: null,
768             fillcolor: null,
769             highlightonsector: false,
770             highlightbysize: false,
771             label: {
772             }
773         },
774 
775         /*special circle options */
776         circle: {
777             hasInnerPoints: false,
778             fillColor: 'none',
779             highlightFillColor: 'none',
780             strokeColor: '#0000ff',
781             highlightStrokeColor: '#C3D9FF',
782             center: {
783                 visible: false,
784                 withLabel: false,
785                 fixed: false,
786                 name: ''
787             },
788             label: {
789                 position: 'urt'
790             }
791         },
792 
793         /* special options for circumcircle of 3 points */
794         circumcircle: {
795             fillColor: 'none',
796             highlightFillColor: 'none',
797             strokeColor: '#0000ff',
798             highlightStrokeColor: '#C3D9FF',
799             center: {               // center point
800                 visible: false,
801                 fixed: false,
802                 withLabel: false,
803                 name: ''
804             }
805         },
806 
807         circumcirclearc: {
808             fillColor: 'none',
809             highlightFillColor: 'none',
810             strokeColor: '#0000ff',
811             highlightStrokeColor: '#C3D9FF',
812             center: {
813                 visible: false,
814                 withLabel: false,
815                 fixed: false,
816                 name: ''
817             }
818         },
819 
820         /* special options for circumcircle sector of 3 points */
821         circumcirclesector: {
822             useDirection: true,
823             fillColor: '#00FF00',
824             highlightFillColor: '#00FF00',
825             fillOpacity: 0.3,
826             highlightFillOpacity: 0.3,
827             strokeColor: '#0000ff',
828             highlightStrokeColor: '#C3D9FF',
829             point: {
830                 visible: false,
831                 fixed: false,
832                 withLabel: false,
833                 name: ''
834             }
835         },
836 
837         /* special conic options */
838         conic: {
839             fillColor: 'none',
840             highlightFillColor: 'none',
841             strokeColor: '#0000ff',
842             highlightStrokeColor: '#C3D9FF',
843             foci: {
844                 // points
845                 fixed: false,
846                 visible: false,
847                 withLabel: false,
848                 name: ''
849             }
850         },
851 
852         /* special curve options */
853         curve: {
854             strokeWidth: 1,
855             strokeColor: '#0000ff',
856             fillColor: 'none',
857             fixed: true,
858 
859             /**#@+
860              * @visprop
861              */
862 
863             /**
864              * The data points of the curve are not connected with straight lines but with bezier curves.
865              * @name JXG.Curve#handDrawing
866              * @type Boolean
867              * @default false
868              */
869             handDrawing: false,
870 
871             /**
872              * The curveType is set in @see generateTerm and used in {@link JXG.Curve#updateCurve}.
873              * Possible values are <ul>
874              * <li>'none'</li>
875              * <li>'plot': Data plot</li>
876              * <li>'parameter': we can not distinguish function graphs and parameter curves</li>
877              * <li>'functiongraph': function graph</li>
878              * <li>'polar'</li>
879              * <li>'implicit' (not yet)</li></ul>
880              * Only parameter and plot are set directly. Polar is set with {@link JXG.GeometryElement#setAttribute} only.
881              * @name JXG.Curve#curveType
882              */
883             curveType: null,
884             RDPsmoothing: false,     // Apply the Ramer-Douglas-Peuker algorithm
885             numberPointsHigh: 1600,  // Number of points on curves after mouseUp
886             numberPointsLow: 400,    // Number of points on curves after mousemove
887             doAdvancedPlot: true,    // Use the algorithm by Gillam and Hohenwarter
888                                      // It is much slower, but the result is better
889 
890             label: {
891                 position: 'lft'
892             }
893 
894             /**#@-*/
895         },
896 
897         glider: {
898             label: {}
899         },
900 
901         /* special grid options */
902         grid: {
903             /**#@+
904              * @visprop
905              */
906 
907             /* grid styles */
908             needsRegularUpdate: false,
909             hasGrid: false,
910             gridX: 1,
911             gridY: 1,
912             //strokeColor: '#C0C0C0',
913             strokeColor: '#C0C0C0',
914             strokeOpacity: 0.5,
915             strokeWidth: 1,
916             dash: 0,    // dashed grids slow down the iPad considerably
917             /* snap to grid options */
918 
919             /**
920              * @deprecated
921              */
922             snapToGrid: false,
923             /**
924              * @deprecated
925              */
926             snapSizeX: 10,
927             /**
928              * @deprecated
929              */
930             snapSizeY: 10
931 
932             /**#@-*/
933         },
934 
935         /* special grid options */
936         image: {
937             imageString: null,
938             fillOpacity: 1.0,
939             cssClass: 'JXGimage',
940             highlightCssClass: 'JXGimageHighlight',
941             rotate: 0
942         },
943 
944         /* special options for incircle of 3 points */
945         incircle: {
946             fillColor: 'none',
947             highlightFillColor: 'none',
948             strokeColor: '#0000ff',
949             highlightStrokeColor: '#C3D9FF',
950             center: {               // center point
951                 visible: false,
952                 fixed: false,
953                 withLabel: false,
954                 name: ''
955             }
956         },
957 
958         inequality: {
959             fillColor: 'red',
960             fillOpacity: 0.2,
961             strokeColor: 'none',
962 
963             /**
964              * By default an inequality is less (or equal) than. Set inverse to <tt>true</tt> will consider the inequality
965              * greater (or equal) than.
966              * @type Boolean
967              * @default false
968              * @name Inequality#inverse
969              * @visprop
970              */
971             inverse: false
972         },
973 
974         infobox: {
975             /**#@+
976              * @visprop
977              */
978 
979             fontSize: 12,
980             isLabel: false,
981             strokeColor: '#bbbbbb',
982             display: 'html',                    // 'html' or 'internal'
983             anchorX: 'left',                     //  'left', 'middle', or 'right': horizontal alignment of the text.
984             anchorY: 'middle',                   //  'top', 'middle', or 'bottom': vertical alignment of the text.
985             cssClass: 'JXGinfobox',
986             rotate: 0,                           // works for non-zero values only in combination with display=='internal'
987             visible: true,
988             parse: false
989 
990             /**#@-*/
991         },
992 
993 
994         /* special options for integral */
995         integral: {
996             axis: 'x',        // 'x' or 'y'
997             withLabel: true,    // Show integral value as text
998             strokeWidth: 0,
999             strokeOpacity: 0,
1000             fillOpacity: 0.8,
1001             curveLeft: {    // Start point
1002                 visible: true,
1003                 withLabel: false,
1004                 layer: 9
1005             },
1006             baseLeft: {    // Start point
1007                 visible: false,
1008                 fixed: false,
1009                 withLabel: false,
1010                 name: ''
1011             },
1012             curveRight: {      // End point
1013                 visible: true,
1014                 withLabel: false,
1015                 layer: 9
1016             },
1017             baseRight: {      // End point
1018                 visible: false,
1019                 fixed: false,
1020                 withLabel: false,
1021                 name: ''
1022             },
1023             label: {
1024                 fontSize: 20
1025             }
1026         },
1027 
1028         /* special intersection point options */
1029         intersection: {
1030             /**#@+
1031              * @visprop
1032              */
1033             /**
1034              * Used in {@link JXG.Intersection}.
1035              * This flag sets the behaviour of intersection points of e.g.
1036              * two segments. If true, the intersection is treated as intersection of lines. If false
1037              * the intersection point exists if the segments intersect setwise.
1038              * @name JXG.Intersection.alwaysIntersect
1039              * @type Boolean
1040              * @default true
1041              */
1042             alwaysIntersect: true
1043             /**#@-*/
1044         },
1045 
1046         /* special label options */
1047         label: {
1048             /**#@+
1049              * @visprop
1050              */
1051             strokeColor: 'black',
1052             strokeOpacity: 1,
1053             highlightStrokeOpacity: 1,
1054             highlightStrokeColor: '#C3D9FF',
1055 
1056             fixed: true,
1057             /**
1058              * Possible string values for the position of a label for
1059              * label anchor points are:
1060              * 'lft'|'rt'|'top'|'bot'|'ulft'|'urt'|'llft'|'lrt'
1061              * This is relevant for non-points: line, circle, curve.
1062              * @type String
1063              * @default 'urt'
1064              * @name JXG.GeometryElement#label.position
1065              */
1066             position: 'urt',
1067 
1068             /**
1069              *  Label offset from label anchor
1070              *  The label anchor is determined by JXG.GeometryElement#label.position
1071              * @type Array
1072              * @default [10,10]
1073              * @name JXG.GeometryElement#label.offset
1074              **/
1075             offset: [10, 10]
1076 
1077             /**#@-*/
1078         },
1079 
1080         /* special legend options */
1081         legend: {
1082             /**
1083              * @visprop
1084              */
1085             style: 'vertical',
1086             labels: ['1', '2', '3', '4', '5', '6', '7', '8'],
1087             colors: ['#B02B2C', '#3F4C6B', '#C79810', '#D15600', '#FFFF88', '#C3D9FF', '#4096EE', '#008C00']
1088         },
1089 
1090         /* special line options */
1091         line: {
1092             /**#@+
1093              * @visprop
1094              */
1095 
1096             firstArrow: false,
1097             lastArrow: false,
1098             straightFirst: true,
1099             straightLast: true,
1100             fillColor: 'none',               // Important for VML on IE
1101             highlightFillColor: 'none',  // Important for VML on IE
1102             strokeColor: '#0000ff',
1103             highlightStrokeColor: '#888888',
1104             withTicks: false,
1105 
1106             /**#@-*/
1107 
1108             point1: {                  // Default values for point1 if created by line
1109                 visible: false,
1110                 withLabel: false,
1111                 fixed: false,
1112                 name: ''
1113             },
1114             point2: {                  // Default values for point2 if created by line
1115                 visible: false,
1116                 withLabel: false,
1117                 fixed: false,
1118                 name: ''
1119             },
1120             ticks: {
1121                 drawLabels: true,
1122                 label: {
1123                     offset: [4, -12 + 3] // This seems to be a good offset for 12 point fonts
1124                 },
1125                 drawZero: false,
1126                 insertTicks: false,
1127                 minTicksDistance: 50,
1128                 maxTicksDistance: 300,
1129                 minorHeight: 4,          // if <0: full width and height
1130                 majorHeight: -1,         // if <0: full width and height
1131                 minorTicks: 4,
1132                 defaultDistance: 1,
1133                 strokeOpacity: 0.3
1134             },
1135 
1136             label: {
1137                 position: 'llft'
1138             },
1139 
1140             /**
1141              * If set to true, the point will snap to a grid defined by
1142              * {@link JXG.Point#snapSizeX} and {@link JXG.Point#snapSizeY}.
1143              * @see JXG.Point#snapSizeX
1144              * @see JXG.Point#snapSizeY
1145              * @type Boolean
1146              * @name JXG.Point#snapToGrid
1147              * @default false
1148              */
1149             snapToGrid: false,
1150 
1151             /**
1152              * Defines together with {@link JXG.Point#snapSizeY} the grid the point snaps on to.
1153              * The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
1154              * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks
1155              * of the default ticks of the default x axes of the board.
1156              * @see JXG.Point#snapToGrid
1157              * @see JXG.Point#snapSizeY
1158              * @see JXG.Board#defaultAxes
1159              * @type Number
1160              * @name JXG.Point#snapSizeX
1161              * @default 1
1162              */
1163             snapSizeX: 1,
1164 
1165             /**
1166              * Defines together with {@link JXG.Point#snapSizeX} the grid the point snaps on to.
1167              * The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
1168              * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks
1169              * of the default ticks of the default y axes of the board.
1170              * @see JXG.Point#snapToGrid
1171              * @see JXG.Point#snapSizeX
1172              * @see JXG.Board#defaultAxes
1173              * @type Number
1174              * @name JXG.Point#snapSizeY
1175              * @default 1
1176              */
1177             snapSizeY: 1
1178         },
1179 
1180         /* special options for locus curves */
1181         locus: {
1182             /**#@+
1183              * @visprop
1184              */
1185 
1186             translateToOrigin: false,
1187             translateTo10: false,
1188             stretch: false,
1189             toOrigin: null,
1190             to10: null
1191             /**#@-*/
1192         },
1193 
1194         /* special options for normal lines */
1195         normal: {
1196             strokeColor: '#000000', //  normal line
1197             point: {
1198                 visible: false,
1199                 fixed: false,
1200                 withLabel: false,
1201                 name: ''
1202             }
1203         },
1204 
1205         /* special options for orthogonal projectionn points */
1206         orthogonalprojection: {
1207         },
1208 
1209         /* special options for parallel lines */
1210         parallel: {
1211             strokeColor: '#000000', // Parallel line
1212             point: {
1213                 visible: false,
1214                 fixed: false,
1215                 withLabel: false,
1216                 name: ''
1217             }
1218         },
1219 
1220         /* special perpendicular options */
1221         perpendicular: {
1222             strokeColor: '#000000', // Perpendicular line
1223             straightFirst: true,
1224             straightLast: true
1225         },
1226 
1227         /* special perpendicular options */
1228         perpendicularsegment: {
1229             strokeColor: '#000000', // Perpendicular segment
1230             straightFirst: false,
1231             straightLast: false,
1232             point: {               // Perpendicular point
1233                 visible: false,
1234                 fixed: true,
1235                 withLabel: false,
1236                 name: ''
1237             }
1238         },
1239 
1240         /* special point options */
1241         point: {
1242             /**#@+
1243              * @visprop
1244              */
1245 
1246             withLabel: true,
1247             label: {},
1248 
1249             /**
1250              * This attribute was used to determined the point layout. It was derived from GEONExT and was
1251              * replaced by {@link JXG.Point#face} and {@link JXG.Point#size}.
1252              * @see JXG.Point#face
1253              * @see JXG.Point#size
1254              * @type Number
1255              * @default JXG.Options.point#style
1256              * @name JXG.Point#style
1257              * @deprecated
1258              */
1259             style: 5,
1260 
1261             /**
1262              * There are different point styles which differ in appearance.
1263              * Posssible values are
1264              * <table><tr><th>Value</th></tr>
1265              * <tr><td>cross</td></tr>
1266              * <tr><td>circle</td></tr>
1267              * <tr><td>square</td></tr>
1268              * <tr><td>plus</td></tr>
1269              * <tr><td>diamond</td></tr>
1270              * <tr><td>triangleUp</td></tr>
1271              * <tr><td>triangleDown</td></tr>
1272              * <tr><td>triangleLeft</td></tr>
1273              * <tr><td>triangleRight</td></tr>
1274              * </table>
1275              * @type string
1276              * @see JXG.Point#setStyle
1277              * @default circle
1278              * @name JXG.Point#face
1279              */
1280             face: 'o',
1281 
1282             /**
1283              * Determines the size of a point.
1284              * Means radius resp. half the width of a point (depending on the face).
1285              * @see JXG.Point#face
1286              * @type number
1287              * @see JXG.Point#setStyle
1288              * @default 3
1289              * @name JXG.Point#size
1290              */
1291             size: 3,
1292             fillColor: '#ff0000',
1293             highlightFillColor: '#EEEEEE',
1294             strokeWidth: 2,
1295             strokeColor: '#ff0000',
1296             highlightStrokeColor: '#C3D9FF',
1297             zoom: false,             // Change the point size on zoom
1298 
1299             /**
1300              * If true, the infobox is shown on mouse over, else not.
1301              * @name JXG.Point#showInfobox
1302              * @type Boolean
1303              * @default true
1304              */
1305             showInfobox: true,
1306 
1307             /**
1308              * Truncating rule for the digits in the infobox.
1309              * 'auto': done automatically by JXG#autoDigits
1310              * 'none': no truncation
1311              * number: use String.toFixed();
1312              * @name JXG.Point#showInfobox
1313              * @type String, Number
1314              * @default true
1315              */
1316             infoboxDigits: 'auto',
1317 
1318             draft: false,
1319 
1320             /**
1321              * List of attractor elements. If the distance of the point is less than
1322              * attractorDistance the point is made to glider of this element.
1323              * @type array
1324              * @name JXG.Point#attractors
1325              * @default empty
1326              */
1327             attractors: [],
1328 
1329             /**
1330              * Unit for attractorDistance and snatchDistance, used for magnetized points and for snapToPoints.
1331              * Possible values are 'screen' and 'user.
1332              * @see JXG.Point#attractorDistance
1333              * @see JXG.Point#snatchDistance
1334              * @see JXG.Point#snapToPoints
1335              * @see JXG.Point#attractors
1336              * @type string
1337              * @name JXG.Point#attractorDistance
1338              * @default 'user'
1339              */
1340             attractorUnit: 'user',    // 'screen', 'user'
1341 
1342             /**
1343              * If the distance of the point to one of its attractors is less
1344              * than this number the point will be a glider on this
1345              * attracting element.
1346              * If set to zero nothing happens.
1347              * @type number
1348              * @name JXG.Point#attractorDistance
1349              * @default 0
1350              */
1351             attractorDistance: 0.0,
1352 
1353             /**
1354              * If the distance of the point to one of its attractors is at least
1355              * this number the point will be released from being a glider on the
1356              * attracting element.
1357              * If set to zero nothing happens.
1358              * @type number
1359              * @name JXG.Point#snatchDistance
1360              * @default 0
1361              */
1362             snatchDistance: 0.0,
1363 
1364             /**
1365              * If set to true, the point will snap to a grid defined by
1366              * {@link JXG.Point#snapSizeX} and {@link JXG.Point#snapSizeY}.
1367              * @see JXG.Point#snapSizeX
1368              * @see JXG.Point#snapSizeY
1369              * @type Boolean
1370              * @name JXG.Point#snapToGrid
1371              * @default false
1372              */
1373             snapToGrid: false,
1374 
1375             /**
1376              * Defines together with {@link JXG.Point#snapSizeY} the grid the point snaps on to.
1377              * The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
1378              * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks
1379              * of the default ticks of the default x axes of the board.
1380              * @see JXG.Point#snapToGrid
1381              * @see JXG.Point#snapSizeY
1382              * @see JXG.Board#defaultAxes
1383              * @type Number
1384              * @name JXG.Point#snapSizeX
1385              * @default 1
1386              */
1387             snapSizeX: 1,
1388 
1389             /**
1390              * Defines together with {@link JXG.Point#snapSizeX} the grid the point snaps on to.
1391              * The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
1392              * If this value is equal to or less than <tt>0</tt>, it will use the grid displayed by the major ticks
1393              * of the default ticks of the default y axes of the board.
1394              * @see JXG.Point#snapToGrid
1395              * @see JXG.Point#snapSizeX
1396              * @see JXG.Board#defaultAxes
1397              * @type Number
1398              * @name JXG.Point#snapSizeY
1399              * @default 1
1400              */
1401             snapSizeY: 1,
1402 
1403             /**
1404              * If set to true, the point will snap to the nearest point in distance of
1405              * {@link JXG.Point#attractorDistance}.
1406              * @see JXG.Point#attractorDistance
1407              * @type Boolean
1408              * @name JXG.Point#snapToPoints
1409              * @default false
1410              */
1411             snapToPoints: false
1412 
1413             /**#@-*/
1414         },
1415 
1416         /* special polygon options */
1417         polygon: {
1418             /**#@+
1419              * @visprop
1420              */
1421 
1422             /**
1423              * If <tt>true</tt>, moving the mouse over inner points triggers hasPoint.
1424              * @see JXG.GeometryElement#hasPoint
1425              * @name JXG.Polygon#hasInnerPoints
1426              * @type Boolean
1427              * @default false
1428              */
1429             hasInnerPoints: false,
1430             fillColor: '#00FF00',
1431             highlightFillColor: '#00FF00',
1432             fillOpacity: 0.3,
1433             highlightFillOpacity: 0.3,
1434 
1435             /**
1436              * Is the polygon bordered by lines?
1437              * @type Boolean
1438              * @name JXG.Polygon#withLines
1439              * @default true
1440              */
1441             withLines: true,
1442 
1443             /**#@-*/
1444 
1445             borders: {
1446                 withLabel: false,
1447                 strokeWidth: 1,
1448                 highlightStrokeWidth: 1,
1449                 // Polygon layer + 1
1450                 layer: 5,
1451                 label: {
1452                     position: 'top'
1453                 }
1454             },
1455 
1456             /**
1457              *  Points for regular polygons
1458              */
1459             vertices: {
1460                 withLabel: true,
1461                 strokeColor: '#ff0000',
1462                 fillColor: '#ff0000',
1463                 fixed: true
1464             },
1465 
1466             label: {
1467                 offset: [0, 0]
1468             }
1469         },
1470 
1471         /* special prescribed angle options */
1472         prescribedangle: {
1473             anglepoint: {
1474                 size: 2,
1475                 visible: false,
1476                 withLabel: false
1477             }
1478         },
1479 
1480         /* special options for riemann sums */
1481         riemannsum: {
1482             withLabel: false,
1483             fillOpacity: 0.3,
1484             fillColor: '#ffff00'
1485         },
1486 
1487         /* special sector options */
1488         sector: {
1489             fillColor: '#00FF00',
1490             highlightFillColor: '#00FF00',
1491             fillOpacity: 0.3,
1492             highlightFillOpacity: 0.3,
1493             highlightOnSector: false,
1494             radiuspoint: {
1495                 visible: false,
1496                 withLabel: false
1497             },
1498             center: {
1499                 visible: false,
1500                 withLabel: false
1501             },
1502             anglepoint: {
1503                 visible: false,
1504                 withLabel: false
1505             },
1506             label: {
1507                 offset: [0, 0]
1508             }
1509         },
1510 
1511         /* special segment options */
1512         segment: {
1513             label: {
1514                 position: 'top'
1515             }
1516         },
1517 
1518         semicircle: {
1519             midpoint: {
1520                 visible: false,
1521                 withLabel: false,
1522                 fixed: false,
1523                 name: ''
1524             }
1525         },
1526 
1527         /* special slider options */
1528         slider: {
1529             /**#@+
1530              * @visprop
1531              */
1532 
1533             /**
1534              * The slider only returns multiples of this value, e.g. for discrete values set this property to <tt>1</tt>. For
1535              * continuous results set this to <tt>-1</tt>.
1536              * @memberOf Slider.prototype
1537              * @name snapWidth
1538              * @type Number
1539              */
1540             snapWidth: -1,      // -1 = deactivated
1541 
1542             /**
1543              * The precision of the slider value displayed in the optional text.
1544              * @memberOf Slider.prototype
1545              * @name precision
1546              * @type Number
1547              */
1548             precision: 2,
1549             firstArrow: false,
1550             lastArrow: false,
1551             withTicks: true,
1552             withLabel: true,
1553 
1554             layer: 9,
1555             showInfobox: false,
1556             name: '',
1557             visible: true,
1558             strokeColor: '#000000',
1559             highlightStrokeColor: '#888888',
1560             fillColor: '#ffffff',
1561             highlightFillColor: 'none',
1562             size: 6,
1563 
1564             /**#@-*/
1565 
1566             point1: {
1567                 needsRegularUpdate: false,
1568                 showInfobox: false,
1569                 withLabel: false,
1570                 visible: false,
1571                 fixed: true,
1572                 name: ''
1573             },
1574             point2: {
1575                 needsRegularUpdate: false,
1576                 showInfobox: false,
1577                 withLabel: false,
1578                 visible: false,
1579                 fixed: true,
1580                 name: ''
1581             },
1582             baseline: {
1583                 needsRegularUpdate: false,
1584                 name: '',
1585                 strokeWidth: 1,
1586                 strokeColor: '#000000',
1587                 highlightStrokeColor: '#888888'
1588             },
1589             /* line ticks options */
1590             ticks: {
1591                 needsRegularUpdate: false,
1592                 drawLabels: false,
1593                 drawZero: true,
1594                 insertTicks: true,
1595                 minorHeight: 4,          // if <0: full width and height
1596                 majorHeight: 10,        // if <0: full width and height
1597                 minorTicks: 0,
1598                 defaultDistance: 1,
1599                 strokeOpacity: 1,
1600                 strokeWidth: 1,
1601                 strokeColor: '#000000'
1602             },
1603             highline: {
1604                 strokeWidth: 3,
1605                 name: '',
1606                 strokeColor: '#000000',
1607                 highlightStrokeColor: '#888888'
1608             },
1609             label: {
1610                 strokeColor: '#000000'
1611             }
1612         },
1613 
1614         /* special tape measure options */
1615         tapemeasure: {
1616             strokeColor: '#000000',
1617             strokeWidth: 2,
1618             highlightStrokeColor: '#000000',
1619             withTicks: true,
1620             withLabel: true,
1621             precision: 2,
1622 
1623             //layer: 9,
1624             point1: {
1625                 strokeColor: '#000000',
1626                 fillColor: '#ffffff',
1627                 fillOpacity: 0.0,
1628                 highlightFillOpacity: 0.1,
1629                 size: 6,
1630                 snapToPoints: true,
1631                 attractorUnit: 'screen',
1632                 attractorDistance: 20,
1633                 showInfobox: false,
1634                 withLabel: false,
1635                 name: ''
1636             },
1637             point2: {
1638                 strokeColor: '#000000',
1639                 fillColor: '#ffffff',
1640                 fillOpacity: 0.0,
1641                 highlightFillOpacity: 0.1,
1642                 size: 6,
1643                 snapToPoints: true,
1644                 attractorUnit: 'screen',
1645                 attractorDistance: 20,
1646                 showInfobox: false,
1647                 withLabel: false,
1648                 name: ''
1649             },
1650             ticks: {
1651                 drawLabels: false,
1652                 drawZero: true,
1653                 insertTicks: true,
1654                 minorHeight: 8,
1655                 majorHeight: 16,
1656                 minorTicks: 4,
1657                 tickEndings: [0, 1],
1658                 defaultDistance: 0.1,
1659                 strokeOpacity: 1,
1660                 strokeWidth: 1,
1661                 strokeColor: '#000000'
1662             },
1663 
1664             label: {
1665                 position: 'top'
1666             }
1667         },
1668 
1669         /* special text options */
1670         text: {
1671             /**#@+
1672              * @visprop
1673              */
1674 
1675             /**
1676              * The font size in pixels.
1677              * @memberOf Text.prototype
1678              * @default 12
1679              * @name fontSize
1680              * @type Number
1681              */
1682             fontSize: 12,
1683 
1684             /**
1685              * Used to round texts given by a number.
1686              * @memberOf Text.prototype
1687              * @default 2
1688              * @name digits
1689              * @type Number
1690              */
1691             digits: 2,
1692 
1693             /**
1694              * If set to
1695              * @memberOf Text.prototype
1696              * @default true
1697              * @name parse
1698              * @type Boolean
1699              */
1700             parse: true,
1701 
1702             /**
1703              * If set to true and caja's sanitizeHTML function can be found it
1704              * will be used to sanitize text output.
1705              * @memberOf Text.prototype
1706              * @default false
1707              * @name useCaja
1708              * @type Boolean
1709              */
1710             useCaja: false,
1711 
1712             /**
1713              * If enabled, the text will be handled as label. Intended for internal use.
1714              * @memberOf Text.prototype
1715              * @default false
1716              * @name isLabel
1717              * @type Boolean
1718              */
1719             isLabel: false,
1720 
1721             strokeColor: 'black',
1722 
1723             /**
1724              * If true the input will be given to ASCIIMathML before rendering.
1725              * @memberOf Text.prototype
1726              * @default false
1727              * @name useASCIIMathML
1728              * @type Boolean
1729              */
1730             useASCIIMathML: false,
1731 
1732             /**
1733              * If true MathJax will be used to render the input string..
1734              * @memberOf Text.prototype
1735              * @default false
1736              * @name useMathJax
1737              * @type Boolean
1738              */
1739             useMathJax: false,
1740 
1741             /**
1742              * Determines the rendering method of the text. Possible values
1743              * include <tt>'html'</tt> and <tt>'internal</tt>.
1744              * @memberOf Text.prototype
1745              * @default 'html'
1746              * @name display
1747              * @type String
1748              */
1749             display: 'html',
1750 
1751             /**
1752              * The horizontal alignment of the text. Possible values include <tt>'left'</tt>, <tt>'middle'</tt>, and
1753              * <tt>'right'</tt>.
1754              * @memberOf Text.prototype
1755              * @default 'left'
1756              * @name anchorX
1757              * @type String
1758              */
1759             anchorX: 'left',
1760 
1761             /**
1762              * The vertical alignment of the text. Possible values include <tt>'top'</tt>, <tt>'middle'</tt>, and
1763              * <tt>'bottom'</tt>.
1764              * @memberOf Text.prototype
1765              * @default 'middle'
1766              * @name anchorY
1767              * @type String
1768              */
1769             anchorY: 'middle',
1770             /**
1771              * The precision of the slider value displayed in the optional text.
1772              * @memberOf Text.prototype
1773              * @name cssClass
1774              * @type String
1775              */
1776             cssClass: 'JXGtext',
1777 
1778             /**
1779              * The precision of the slider value displayed in the optional text.
1780              * @memberOf Text.prototype
1781              * @name highlightCssClass
1782              * @type String
1783              */
1784             highlightCssClass: 'JXGtext',
1785             dragArea: 'all',                  // 'all', or something else (may be extended to left, right, ...)
1786             withLabel: false,
1787             rotate: 0,                        // works for non-zero values only in combination with display=='internal'
1788             visible: true
1789 
1790             /**#@-*/
1791         },
1792 
1793         /* special options for trace curves */
1794         tracecurve: {
1795             /**#@+
1796              * @visprop
1797              */
1798             strokeColor: '#000000',
1799             fillColor: 'none',
1800 
1801             /**
1802              * The number of evaluated data points.
1803              * @memberOf Tracecurve.prototype
1804              * @default 100
1805              * @name numberPoints
1806              * @type Number
1807              */
1808             numberPoints: 100
1809 
1810             /**#@-*/
1811         },
1812 
1813         /*special turtle options */
1814         turtle: {
1815             strokeWidth: 1,
1816             fillColor: 'none',
1817             strokeColor: '#000000',
1818             arrow: {
1819                 strokeWidth: 2,
1820                 withLabel: false,
1821                 strokeColor: '#ff0000'
1822             }
1823         },
1824 
1825 
1826         /**
1827          * Abbreviations of properties. Setting the shortcut means setting abbreviated properties
1828          * to the same value.
1829          * It is used in JXG.GeometryElement#setAttribute and in
1830          * the constructor JXG.GeometryElement.
1831          * Attention: In Options.js abbreviations are not allowed.
1832          */
1833         shortcuts: {
1834             color: ['strokeColor', 'fillColor'],
1835             opacity: ['strokeOpacity', 'fillOpacity'],
1836             highlightColor: ['highlightStrokeColor', 'highlightFillColor'],
1837             highlightOpacity: ['highlightStrokeOpacity', 'highlightFillOpacity'],
1838             strokeWidth: ['strokeWidth', 'highlightStrokeWidth']
1839         }
1840 
1841     };
1842 
1843     /**
1844      * Holds all possible properties and the according validators for geometry elements. A validator is either a function
1845      * which takes one parameter and returns true, if the value is valid for the property, or it is false if no validator
1846      * is required.
1847      */
1848     JXG.Validator = (function () {
1849         var i,
1850             validatePixel = function (v) {
1851                 return (/^[0-9]+px$/).test(v);
1852             },
1853             validateDisplay = function (v) {
1854                 return (v  === 'html' || v === 'internal');
1855             },
1856             validateColor = function (v) {
1857                 // for now this should do it...
1858                 return Type.isString(v);
1859             },
1860             validatePointFace = function (v) {
1861                 return Type.exists(JXG.normalizePointFace(v));
1862             },
1863             validateInteger = function (v) {
1864                 return (Math.abs(v - Math.round(v)) < Mat.eps);
1865             },
1866             validatePositiveInteger = function (v) {
1867                 return validateInteger(v) && v > 0;
1868             },
1869             validateScreenCoords = function (v) {
1870                 return v.length >= 2 && validateInteger(v[0]) && validateInteger(v[1]);
1871             },
1872             validateRenderer = function (v) {
1873                 return (v === 'vml' || v === 'svg' || v === 'canvas' || v === 'no');
1874             },
1875             validatePositive = function (v) {
1876                 return v > 0;
1877             },
1878             validateNotNegative = function (v) {
1879                 return v >= 0;
1880             },
1881             v = {},
1882             validators = {
1883                 attractorDistance: validateNotNegative,
1884                 color: validateColor,
1885                 defaultDistance: Type.isNumber,
1886                 display: validateDisplay,
1887                 doAdvancedPlot: false,
1888                 draft: false,
1889                 drawLabels: false,
1890                 drawZero: false,
1891                 face: validatePointFace,
1892                 factor: Type.isNumber,
1893                 fillColor: validateColor,
1894                 fillOpacity: Type.isNumber,
1895                 firstArrow: false,
1896                 fontSize: validateInteger,
1897                 dash: validateInteger,
1898                 gridX: Type.isNumber,
1899                 gridY: Type.isNumber,
1900                 hasGrid: false,
1901                 highlightFillColor: validateColor,
1902                 highlightFillOpacity: Type.isNumber,
1903                 highlightStrokeColor: validateColor,
1904                 highlightStrokeOpacity: Type.isNumber,
1905                 insertTicks: false,
1906                 //: validateScreenCoords,
1907                 lastArrow: false,
1908                 majorHeight: validateInteger,
1909                 maxTicksDistance: validatePositiveInteger,
1910                 minorHeight: validateInteger,
1911                 minorTicks: validatePositiveInteger,
1912                 minTicksDistance: validatePositiveInteger,
1913                 numberPointsHigh: validatePositiveInteger,
1914                 numberPointsLow: validatePositiveInteger,
1915                 opacity: Type.isNumber,
1916                 radius: Type.isNumber,
1917                 RDPsmoothing: false,
1918                 renderer: validateRenderer,
1919                 right: validatePixel,
1920                 showCopyright: false,
1921                 showInfobox: false,
1922                 showNavigation: false,
1923                 size: validateInteger,
1924                 snapSizeX: validatePositive,
1925                 snapSizeY: validatePositive,
1926                 snapWidth: Type.isNumber,
1927                 snapToGrid: false,
1928                 snatchDistance: validateNotNegative,
1929                 straightFirst: false,
1930                 straightLast: false,
1931                 stretch: false,
1932                 strokeColor: validateColor,
1933                 strokeOpacity: Type.isNumber,
1934                 strokeWidth: validateInteger,
1935                 takeFirst: false,
1936                 takeSizeFromFile: false,
1937                 to10: false,
1938                 toOrigin: false,
1939                 translateTo10: false,
1940                 translateToOrigin: false,
1941                 useASCIIMathML: false,
1942                 useDirection: false,
1943                 useMathJax: false,
1944                 withLabel: false,
1945                 withTicks: false,
1946                 zoom: false
1947             };
1948 
1949         // this seems like a redundant step but it makes sure that
1950         // all properties in the validator object have lower case names
1951         // and the validator object is easier to read.
1952         for (i in validators) {
1953             if (validators.hasOwnProperty(i)) {
1954                 v[i.toLowerCase()] = validators[i];
1955             }
1956         }
1957 
1958         return v;
1959     }());
1960 
1961     /**
1962      * All point faces can be defined with more than one name, e.g. a cross faced point can be given
1963      * by face equal to 'cross' or equal to 'x'. This method maps all possible values to fixed ones to
1964      * simplify if- and switch-clauses regarding point faces. The translation table is as follows:
1965      * <table>
1966      * <tr><th>Input</th><th>Output</th></tr>
1967      * <tr><td>cross, x</td><td>x</td></tr>
1968      * <tr><td>circle, o</td><td>o</td></tr>
1969      * <tr><td>square, []</td><td>[]</td></tr>
1970      * <tr><td>plus, +</td><td>+</td></tr>
1971      * <tr><td>diamond, <></td><td><></td></tr>
1972      * <tr><td>triangleup, a, ^</td><td>A</td></tr>
1973      * <tr><td>triangledown, v</td><td>v</td></tr>
1974      * <tr><td>triangleleft, <</td><td><</td></tr>
1975      * <tr><td>triangleright, ></td><td>></td></tr>
1976      * </table>
1977      * @param {String} s A string which should determine a valid point face.
1978      * @returns {String} Returns a normalized string or undefined if the given string is not a valid
1979      * point face.
1980      */
1981     JXG.normalizePointFace = function (s) {
1982         var map = {
1983             cross: 'x',
1984             x: 'x',
1985             circle: 'o',
1986             o: 'o',
1987             square: '[]',
1988             '[]': '[]',
1989             plus: '+',
1990             '+': '+',
1991             diamond: '<>',
1992             '<>': '<>',
1993             triangleup: '^',
1994             a: '^',
1995             '^': '^',
1996             triangledown: 'v',
1997             v: 'v',
1998             triangleleft: '<',
1999             '<': '<',
2000             triangleright: '>',
2001             '>': '>'
2002         };
2003 
2004         return map[s];
2005     };
2006 
2007 
2008     /**
2009      * Apply the options stored in this object to all objects on the given board.
2010      * @param {JXG.Board} board The board to which objects the options will be applied.
2011      */
2012     JXG.useStandardOptions = function (board) {
2013         var el, t, p, copyProps,
2014             o = JXG.Options,
2015             boardHadGrid = board.hasGrid;
2016 
2017         board.options.grid.hasGrid = o.grid.hasGrid;
2018         board.options.grid.gridX = o.grid.gridX;
2019         board.options.grid.gridY = o.grid.gridY;
2020         board.options.grid.gridColor = o.grid.gridColor;
2021         board.options.grid.gridOpacity = o.grid.gridOpacity;
2022         board.options.grid.gridDash = o.grid.gridDash;
2023         board.options.grid.snapToGrid = o.grid.snapToGrid;
2024         board.options.grid.snapSizeX = o.grid.SnapSizeX;
2025         board.options.grid.snapSizeY = o.grid.SnapSizeY;
2026         board.takeSizeFromFile = o.takeSizeFromFile;
2027 
2028         copyProps = function (p, o) {
2029             p.visProp.fillcolor = o.fillColor;
2030             p.visProp.highlightfillcolor = o.highlightFillColor;
2031             p.visProp.strokecolor = o.strokeColor;
2032             p.visProp.highlightstrokecolor = o.highlightStrokeColor;
2033         };
2034 
2035         for (el in board.objects) {
2036             if (board.objects.hasOwnProperty(el)) {
2037                 p = board.objects[el];
2038                 if (p.elementClass === Const.OBJECT_CLASS_POINT) {
2039                     copyProps(p, o.point);
2040                 } else if (p.elementClass === Const.OBJECT_CLASS_LINE) {
2041                     copyProps(p, o.line);
2042 
2043                     for (t = 0; t < p.ticks.length; t++) {
2044                         p.ticks[t].majorTicks = o.line.ticks.majorTicks;
2045                         p.ticks[t].minTicksDistance = o.line.ticks.minTicksDistance;
2046                         p.ticks[t].visProp.minorheight = o.line.ticks.minorHeight;
2047                         p.ticks[t].visProp.majorheight = o.line.ticks.majorHeight;
2048                     }
2049                 } else if (p.elementClass === Const.OBJECT_CLASS_CIRCLE) {
2050                     copyProps(p, o.circle);
2051                 } else if (p.type === Const.OBJECT_TYPE_ANGLE) {
2052                     copyProps(p, o.angle);
2053                 } else if (p.type === Const.OBJECT_TYPE_ARC) {
2054                     copyProps(p, o.arc);
2055                 } else if (p.type === Const.OBJECT_TYPE_POLYGON) {
2056                     copyProps(p, o.polygon);
2057                 } else if (p.type === Const.OBJECT_TYPE_CONIC) {
2058                     copyProps(p, o.conic);
2059                 } else if (p.type === Const.OBJECT_TYPE_CURVE) {
2060                     copyProps(p, o.curve);
2061                 } else if (p.type === Const.OBJECT_TYPE_SECTOR) {
2062                     p.arc.visProp.fillcolor = o.sector.fillColor;
2063                     p.arc.visProp.highlightfillcolor = o.sector.highlightFillColor;
2064                     p.arc.visProp.fillopacity = o.sector.fillOpacity;
2065                     p.arc.visProp.highlightfillopacity = o.sector.highlightFillOpacity;
2066                 }
2067             }
2068         }
2069 
2070         board.fullUpdate();
2071         if (boardHadGrid && !board.hasGrid) {
2072             board.removeGrids(board);
2073         } else if (!boardHadGrid && board.hasGrid) {
2074             board.create('grid', []);
2075         }
2076     };
2077 
2078     /**
2079      * Converts all color values to greyscale and calls useStandardOption to put them onto the board.
2080      * @param {JXG.Board} board The board to which objects the options will be applied.
2081      * @see #useStandardOptions
2082      */
2083     JXG.useBlackWhiteOptions = function (board) {
2084         var o = JXG.Options;
2085         o.point.fillColor = Color.rgb2bw(o.point.fillColor);
2086         o.point.highlightFillColor = Color.rgb2bw(o.point.highlightFillColor);
2087         o.point.strokeColor = Color.rgb2bw(o.point.strokeColor);
2088         o.point.highlightStrokeColor = Color.rgb2bw(o.point.highlightStrokeColor);
2089 
2090         o.line.fillColor = Color.rgb2bw(o.line.fillColor);
2091         o.line.highlightFillColor = Color.rgb2bw(o.line.highlightFillColor);
2092         o.line.strokeColor = Color.rgb2bw(o.line.strokeColor);
2093         o.line.highlightStrokeColor = Color.rgb2bw(o.line.highlightStrokeColor);
2094 
2095         o.circle.fillColor = Color.rgb2bw(o.circle.fillColor);
2096         o.circle.highlightFillColor = Color.rgb2bw(o.circle.highlightFillColor);
2097         o.circle.strokeColor = Color.rgb2bw(o.circle.strokeColor);
2098         o.circle.highlightStrokeColor = Color.rgb2bw(o.circle.highlightStrokeColor);
2099 
2100         o.arc.fillColor = Color.rgb2bw(o.arc.fillColor);
2101         o.arc.highlightFillColor = Color.rgb2bw(o.arc.highlightFillColor);
2102         o.arc.strokeColor = Color.rgb2bw(o.arc.strokeColor);
2103         o.arc.highlightStrokeColor = Color.rgb2bw(o.arc.highlightStrokeColor);
2104 
2105         o.polygon.fillColor = Color.rgb2bw(o.polygon.fillColor);
2106         o.polygon.highlightFillColor  = Color.rgb2bw(o.polygon.highlightFillColor);
2107 
2108         o.sector.fillColor = Color.rgb2bw(o.sector.fillColor);
2109         o.sector.highlightFillColor  = Color.rgb2bw(o.sector.highlightFillColor);
2110 
2111         o.curve.strokeColor = Color.rgb2bw(o.curve.strokeColor);
2112         o.grid.gridColor = Color.rgb2bw(o.grid.gridColor);
2113 
2114         JXG.useStandardOptions(board);
2115     };
2116 
2117     // needs to be exported
2118     JXG.Options.normalizePointFace = JXG.normalizePointFace;
2119 
2120     return JXG.Options;
2121 });
2122