equal
deleted
inserted
replaced
1 // widget_pathslider.ysl2 |
1 // widget_pathslider.ysl2 |
2 widget_desc("PathSlider") { |
2 widget_desc("PathSlider") { |
3 longdesc |
3 longdesc |
4 || |
4 || |
5 PathSlider - |
5 PathSlider - |
6 || |
6 || |
7 |
7 |
8 shortdesc > Slide an SVG element along a path by dragging it |
8 shortdesc > Slide an SVG element along a path by dragging it |
9 |
9 |
10 path name="value" accepts="HMI_INT,HMI_REAL" > value |
10 path name="value" accepts="HMI_INT,HMI_REAL" > value |
11 path name="min" count="optional" accepts="HMI_INT,HMI_REAL" > min |
11 path name="min" count="optional" accepts="HMI_INT,HMI_REAL" > min |
12 path name="max" count="optional" accepts="HMI_INT,HMI_REAL" > max |
12 path name="max" count="optional" accepts="HMI_INT,HMI_REAL" > max |
13 |
13 |
14 arg name="min" count="optional" accepts="int,real" > minimum value |
14 arg name="min" count="optional" accepts="int,real" > minimum value |
15 arg name="max" count="optional" accepts="int,real" > maximum value |
15 arg name="max" count="optional" accepts="int,real" > maximum value |
16 } |
16 } |
17 |
17 |
18 widget_class("PathSlider") { |
18 widget_class("PathSlider") { |
23 max = 100; |
23 max = 100; |
24 scannedPoints = []; |
24 scannedPoints = []; |
25 pathLength = undefined; |
25 pathLength = undefined; |
26 precision = undefined; |
26 precision = undefined; |
27 origPt = undefined; |
27 origPt = undefined; |
28 |
28 |
29 |
29 |
30 scanPath() { |
30 scanPath() { |
31 this.pathLength = this.path_elt.getTotalLength(); |
31 this.pathLength = this.path_elt.getTotalLength(); |
32 this.precision = Math.floor(this.pathLength / 10); |
32 this.precision = Math.floor(this.pathLength / 10); |
33 |
33 |
65 if ((beforeLength = bestLength - precision) >= 0 && |
65 if ((beforeLength = bestLength - precision) >= 0 && |
66 (beforeDistance = distance2(beforePoint = this.path_elt.getPointAtLength(beforeLength))) < bestDistance) { |
66 (beforeDistance = distance2(beforePoint = this.path_elt.getPointAtLength(beforeLength))) < bestDistance) { |
67 bestPoint = beforePoint, |
67 bestPoint = beforePoint, |
68 bestLength = beforeLength, |
68 bestLength = beforeLength, |
69 bestDistance = beforeDistance; |
69 bestDistance = beforeDistance; |
70 } else if ((afterLength = bestLength + precision) <= this.pathLength && |
70 } else if ((afterLength = bestLength + precision) <= this.pathLength && |
71 (afterDistance = distance2(afterPoint = this.path_elt.getPointAtLength(afterLength))) < bestDistance) { |
71 (afterDistance = distance2(afterPoint = this.path_elt.getPointAtLength(afterLength))) < bestDistance) { |
72 bestPoint = afterPoint, |
72 bestPoint = afterPoint, |
73 bestLength = afterLength, |
73 bestLength = afterLength, |
74 bestDistance = afterDistance; |
74 bestDistance = afterDistance; |
75 } |
75 } |