maidr 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.Rbuildignore +1 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +6 -0
- package/.github/workflows/build.yml +20 -0
- package/.prettierignore +3 -0
- package/.prettierrc.json +7 -0
- package/.vscode/extensions.json +25 -0
- package/.vscode/settings.json +30 -0
- package/.vscode/tasks.json +57 -0
- package/CHANGELOG.md +7 -0
- package/CITATION.cff +21 -0
- package/CONTRIBUTING.md +87 -0
- package/LICENSE.md +595 -0
- package/README.md +341 -0
- package/dist/maidr.js +8851 -0
- package/dist/maidr.min.js +1 -0
- package/dist/styles.css +244 -0
- package/dist/styles.min.css +1 -0
- package/docs/Audio.html +1398 -0
- package/docs/Constants.html +256 -0
- package/docs/Description.html +582 -0
- package/docs/Helper.html +364 -0
- package/docs/LogError.html +905 -0
- package/docs/Menu.html +665 -0
- package/docs/Position.html +174 -0
- package/docs/Resources.html +338 -0
- package/docs/Review.html +333 -0
- package/docs/Tracker.html +965 -0
- package/docs/audio.js.html +635 -0
- package/docs/constants.js.html +1242 -0
- package/docs/display.js.html +1184 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docs/index.html +66 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +692 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/examples/dev_charts/barplot.html +1056 -0
- package/examples/dev_charts/boxplot.html +1856 -0
- package/examples/dev_charts/boxplot_flipped.svg +727 -0
- package/examples/dev_charts/heatmap.html +1217 -0
- package/examples/dev_charts/scatterplot/displ.js +18 -0
- package/examples/dev_charts/scatterplot/histogram_for_residual.svg +595 -0
- package/examples/dev_charts/scatterplot/hwy.js +15 -0
- package/examples/dev_charts/scatterplot/layers/point_layer.json +938 -0
- package/examples/dev_charts/scatterplot/layers/smooth_layer.json +322 -0
- package/examples/dev_charts/scatterplot/point_layer.js +938 -0
- package/examples/dev_charts/scatterplot/prediction_array.js +31 -0
- package/examples/dev_charts/scatterplot/prediction_array.json +31 -0
- package/examples/dev_charts/scatterplot/residual_array.js +29 -0
- package/examples/dev_charts/scatterplot/residual_array.json +29 -0
- package/examples/dev_charts/scatterplot/scatterplot.svg +1428 -0
- package/examples/dev_charts/scatterplot/scatterplot_data.html +2838 -0
- package/examples/dev_charts/scatterplot/scatterplot_no_jitter_point_only.svg +1393 -0
- package/examples/dev_charts/scatterplot/scatterplot_no_jitter_with_bestfit.svg +1424 -0
- package/examples/dev_charts/scatterplot/scatterplot_no_jitter_with_loess_curve.svg +1402 -0
- package/examples/dev_charts/scatterplot/smooth_layer.js +322 -0
- package/examples/dev_charts/scatterplot.html +4560 -0
- package/examples/dodged_bar/dodged_bar.png +0 -0
- package/examples/dodged_bar/dodged_bar.svg +198 -0
- package/examples/dodged_bar/schema.json +41 -0
- package/examples/histogram/histogram_tutorial.svg +482 -0
- package/examples/histogram/histogram_tutorial_raw_data.json +362 -0
- package/examples/histogram/histogram_user_study.svg +578 -0
- package/examples/histogram/histogram_user_study_raw_data.json +362 -0
- package/examples/lineplot/lineplot_sample.svg +126 -0
- package/examples/lineplot/lineplot_sample_raw_data.json +1 -0
- package/examples/lineplot/point+lineplot_sample.svg +700 -0
- package/examples/other/audio_oscillator_boxplot.js +95 -0
- package/examples/other/barplot_labels.svg +314 -0
- package/examples/other/barplot_user_study.svg +313 -0
- package/examples/other/boxplot.html +927 -0
- package/examples/other/boxplot_data_frame.html +568 -0
- package/examples/other/boxplot_label.svg +751 -0
- package/examples/other/braille-display_boxplot.js +79 -0
- package/examples/other/control_boxplot.js +55 -0
- package/examples/other/draft.js +56 -0
- package/examples/other/getData.html +400 -0
- package/examples/other/getData.js +41 -0
- package/examples/other/ggplot_to_svg.R +371 -0
- package/examples/other/heatmap.svg +582 -0
- package/examples/other/heatmap_label.svg +608 -0
- package/examples/other/multiple_barplot.html +2250 -0
- package/examples/other/new_scatterplot_user_study_point_layer.json +122 -0
- package/examples/other/py_binder_output.html +1167 -0
- package/examples/other/scatterplot_label.svg +1429 -0
- package/examples/other/seaborn_plot.py +9 -0
- package/examples/other/svglite_bar.svg +136 -0
- package/examples/other/tutorial_boxplot.svg +727 -0
- package/examples/other/tutorial_boxplot_data.json +72 -0
- package/examples/other/user_study_boxplot.svg +676 -0
- package/examples/stacked_bar/schema.json +41 -0
- package/examples/stacked_bar/stack_bar.png +0 -0
- package/examples/stacked_bar/stacked_bar.svg +180 -0
- package/examples/stacked_normalized_bar/stacked_normalized_bar.png +0 -0
- package/examples/stacked_normalized_bar/stacked_normalized_bar.svg +189 -0
- package/examples/static/barplot.svg +263 -0
- package/examples/static/barplot_diamonds_gridSVG.svg +254 -0
- package/examples/static/boxplot.svg +424 -0
- package/examples/static/heatmap.svg +373 -0
- package/examples/static/heatmap_penguins_table.html +486 -0
- package/examples/static/scatterplot.svg +530 -0
- package/examples/svglite/task_heatmap.html +802 -0
- package/examples/svglite/task_heatmap.svg +111 -0
- package/examples/svglite/tutorial_bar.svg +136 -0
- package/examples/svglite/tutorial_bar_plot.html +504 -0
- package/examples/svglite/tutorial_boxplot.html +1850 -0
- package/examples/svglite/tutorial_boxplot.svg +727 -0
- package/examples/svglite/tutorial_scatterplot.html +3135 -0
- package/examples/svglite/tutorial_scatterplot.svg +311 -0
- package/gulpfile.js +49 -0
- package/index.html +40 -0
- package/jsconfig.json +10 -0
- package/jsdoc.json +19 -0
- package/package.json +47 -0
- package/src/css/styles.css +241 -0
- package/src/js/__tests__/audio.test.js +49 -0
- package/src/js/__tests__/constants.test.js +622 -0
- package/src/js/audio.js +575 -0
- package/src/js/barplot.js +254 -0
- package/src/js/boxplot.js +682 -0
- package/src/js/constants.js +1182 -0
- package/src/js/controls.js +3182 -0
- package/src/js/display.js +1124 -0
- package/src/js/heatmap.js +411 -0
- package/src/js/histogram.js +134 -0
- package/src/js/init.js +427 -0
- package/src/js/lineplot.js +219 -0
- package/src/js/scatterplot.js +619 -0
- package/src/js/segmented.js +268 -0
- package/user_study_pilot/binder_test.html +526 -0
- package/user_study_pilot/data/barplot_user_study.svg +492 -0
- package/user_study_pilot/data/barplot_user_study_raw_data.json +22 -0
- package/user_study_pilot/data/boxplot_tutorial.json +72 -0
- package/user_study_pilot/data/boxplot_tutorial_horizontal.svg +727 -0
- package/user_study_pilot/data/boxplot_user_study.json +52 -0
- package/user_study_pilot/data/boxplot_user_study_vertical.svg +675 -0
- package/user_study_pilot/data/boxplot_user_study_vertical_horizontal.svg +676 -0
- package/user_study_pilot/data/heatmap_user_study.svg +719 -0
- package/user_study_pilot/data/heatmap_user_study_raw_data.json +127 -0
- package/user_study_pilot/data/new_barplot_user_study.svg +269 -0
- package/user_study_pilot/data/new_heatmap_user_study.svg +367 -0
- package/user_study_pilot/data/new_scatterplot_user_study.svg +603 -0
- package/user_study_pilot/data/new_scatterplot_user_study_point_layer.json +122 -0
- package/user_study_pilot/data/scatterplot_user_study (1).svg +321 -0
- package/user_study_pilot/data/scatterplot_user_study.svg +603 -0
- package/user_study_pilot/data/scatterplot_user_study_point_layer.json +122 -0
- package/user_study_pilot/data/scatterplot_user_study_smooth_layer.json +322 -0
- package/user_study_pilot/intro.html +215 -0
- package/user_study_pilot/jaws_settings/Chrome.JDF +10 -0
- package/user_study_pilot/jaws_settings/Firefox.JDF +10 -0
- package/user_study_pilot/jaws_settings/backup_utf8/Chrome.JDF +10 -0
- package/user_study_pilot/jaws_settings/backup_utf8/Firefox.JDF +10 -0
- package/user_study_pilot/jaws_settings/backup_utf8/msedge.JDF +10 -0
- package/user_study_pilot/jaws_settings/msedge.JDF +10 -0
- package/user_study_pilot/nvda_settings/chrome.dic +10 -0
- package/user_study_pilot/nvda_settings/default.dic +10 -0
- package/user_study_pilot/nvda_settings/firefox.dic +10 -0
- package/user_study_pilot/nvda_settings/msedge.dic +10 -0
- package/user_study_pilot/scatterplot.html +4560 -0
- package/user_study_pilot/seaborn_test.html +1059 -0
- package/user_study_pilot/svglite_test.html +534 -0
- package/user_study_pilot/task1_bar_plot.html +1111 -0
- package/user_study_pilot/task2_heatmap.html +1661 -0
- package/user_study_pilot/task3_boxplot_horizontal.html +1690 -0
- package/user_study_pilot/task3_boxplot_vertical.html +1689 -0
- package/user_study_pilot/task4_scatterplot.html +2091 -0
- package/user_study_pilot/tutorial1_bar_plot.html +1159 -0
- package/user_study_pilot/tutorial2_heatmap.html +1276 -0
- package/user_study_pilot/tutorial3_boxplot_horizontal.html +1861 -0
- package/user_study_pilot/tutorial3_boxplot_vertical.html +1807 -0
- package/user_study_pilot/tutorial4_scatterplot.html +5893 -0
- package/user_study_pilot/tutorial5_histogram.html +1553 -0
- package/user_study_pilot/tutorial6_lineplot.html +1011 -0
- package/user_study_pilot/tutorial7_stacked.html +763 -0
- package/user_study_pilot/tutorial8_stacked_normalized.html +796 -0
- package/user_study_pilot/tutorial9_dodged_bar.html +831 -0
- package/user_study_pilot/voiceover_settings/user_study_VoiceOver Archive.voprefs +573 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
class Segmented {
|
|
2
|
+
constructor() {
|
|
3
|
+
// initialize variables level, data, and elements
|
|
4
|
+
let level = null;
|
|
5
|
+
let fill = null;
|
|
6
|
+
let data = null;
|
|
7
|
+
let elements = null;
|
|
8
|
+
if ('axes' in singleMaidr) {
|
|
9
|
+
//axes.x.level
|
|
10
|
+
if ('x' in singleMaidr.axes) {
|
|
11
|
+
if ('level' in singleMaidr.axes.x) {
|
|
12
|
+
level = singleMaidr.axes.x.level;
|
|
13
|
+
}
|
|
14
|
+
} else if ('y' in singleMaidr.axes) {
|
|
15
|
+
if ('level' in singleMaidr.axes.y) {
|
|
16
|
+
level = singleMaidr.axes.y.level;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// axes.fill
|
|
20
|
+
if ('fill' in singleMaidr.axes) {
|
|
21
|
+
if ('level' in singleMaidr.axes.fill) {
|
|
22
|
+
fill = singleMaidr.axes.fill.level;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if ('data' in singleMaidr) {
|
|
27
|
+
data = singleMaidr.data;
|
|
28
|
+
}
|
|
29
|
+
if ('elements' in singleMaidr) {
|
|
30
|
+
elements = singleMaidr.elements;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// gracefull failure: must have level + fill + data, elements optional
|
|
34
|
+
if (elements == null) {
|
|
35
|
+
LogError.LogAbsentElement('elements');
|
|
36
|
+
constants.hasRect = 0;
|
|
37
|
+
}
|
|
38
|
+
if (level != null && fill != null && data != null) {
|
|
39
|
+
this.level = level;
|
|
40
|
+
this.fill = fill.reverse(); // typically fill is in reverse order
|
|
41
|
+
let dataAndELements = this.ParseData(data, elements);
|
|
42
|
+
this.plotData = dataAndELements[0];
|
|
43
|
+
this.elements = dataAndELements[1];
|
|
44
|
+
} else {
|
|
45
|
+
console.log(
|
|
46
|
+
'Segmented chart missing level, fill, or data. Unable to create chart.'
|
|
47
|
+
);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// column labels, both legend and tick
|
|
52
|
+
let legendX = '';
|
|
53
|
+
let legendY = '';
|
|
54
|
+
if ('axes' in singleMaidr) {
|
|
55
|
+
// legend labels
|
|
56
|
+
if (singleMaidr.axes.x) {
|
|
57
|
+
if (singleMaidr.axes.x.label) {
|
|
58
|
+
legendX = singleMaidr.axes.x.label;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (singleMaidr.axes.y) {
|
|
62
|
+
if (singleMaidr.axes.y.label) {
|
|
63
|
+
legendY = singleMaidr.axes.y.label;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// labels override axes
|
|
68
|
+
if ('labels' in singleMaidr) {
|
|
69
|
+
if ('x' in singleMaidr.labels) {
|
|
70
|
+
legendX = singleMaidr.labels.x;
|
|
71
|
+
}
|
|
72
|
+
if ('y' in singleMaidr.labels) {
|
|
73
|
+
legendY = singleMaidr.labels.y;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.plotLegend = {
|
|
78
|
+
x: legendX,
|
|
79
|
+
y: legendY,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// title
|
|
83
|
+
this.title = '';
|
|
84
|
+
if ('labels' in singleMaidr) {
|
|
85
|
+
if ('title' in singleMaidr.labels) {
|
|
86
|
+
this.title = singleMaidr.labels.title;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (this.title == '') {
|
|
90
|
+
if ('title' in singleMaidr) {
|
|
91
|
+
this.title = singleMaidr.title;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// subtitle
|
|
96
|
+
if ('labels' in singleMaidr) {
|
|
97
|
+
if ('subtitle' in singleMaidr.labels) {
|
|
98
|
+
this.subtitle = singleMaidr.labels.subtitle;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// caption
|
|
102
|
+
if ('labels' in singleMaidr) {
|
|
103
|
+
if ('caption' in singleMaidr.labels) {
|
|
104
|
+
this.caption = singleMaidr.labels.caption;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// set the max and min values for the plot
|
|
109
|
+
this.SetMaxMin();
|
|
110
|
+
|
|
111
|
+
// create summary and all levels
|
|
112
|
+
this.CreateSummaryLevel();
|
|
113
|
+
this.CreateAllLevel();
|
|
114
|
+
|
|
115
|
+
this.autoplay = null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ParseData(data, elements = null) {
|
|
119
|
+
let plotData = [];
|
|
120
|
+
let plotElements = [];
|
|
121
|
+
|
|
122
|
+
if (elements.length != data.length) {
|
|
123
|
+
plotElements = null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// create a full 2d array of data using level and fill
|
|
127
|
+
for (let i = 0; i < this.level.length; i++) {
|
|
128
|
+
for (let j = 0; j < this.fill.length; j++) {
|
|
129
|
+
// loop through data, find matching level and fill, assign value
|
|
130
|
+
// if no match, assign null
|
|
131
|
+
for (let k = 0; k < data.length; k++) {
|
|
132
|
+
// init
|
|
133
|
+
if (!plotData[i]) {
|
|
134
|
+
plotData[i] = [];
|
|
135
|
+
if (plotElements != null) {
|
|
136
|
+
if (!plotElements[i]) {
|
|
137
|
+
plotElements[i] = [];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!plotData[i][j]) {
|
|
142
|
+
plotData[i][j] = 0;
|
|
143
|
+
if (plotElements != null) {
|
|
144
|
+
if (!plotElements[i][j]) {
|
|
145
|
+
plotElements[i][j] = null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// set actual values
|
|
150
|
+
if (data[k].x == this.level[i] && data[k].fill == this.fill[j]) {
|
|
151
|
+
plotData[i][j] = data[k].y;
|
|
152
|
+
plotElements[i][j] = elements[k];
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return [plotData, plotElements];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
CreateSummaryLevel() {
|
|
163
|
+
// create another y level that is the sum of all the other levels
|
|
164
|
+
|
|
165
|
+
for (let i = 0; i < this.plotData.length; i++) {
|
|
166
|
+
let sum = 0;
|
|
167
|
+
for (let j = 0; j < this.plotData[i].length; j++) {
|
|
168
|
+
sum += this.plotData[i][j];
|
|
169
|
+
}
|
|
170
|
+
this.plotData[i].push(sum);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.fill.push('Sum');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
CreateAllLevel() {
|
|
177
|
+
// create another y level that plays all the other levels seperately
|
|
178
|
+
|
|
179
|
+
for (let i = 0; i < this.plotData.length; i++) {
|
|
180
|
+
let all = [];
|
|
181
|
+
for (let j = 0; j < this.fill.length; j++) {
|
|
182
|
+
if (this.fill[j] != 'Sum') {
|
|
183
|
+
all.push(this.plotData[i][j]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
this.plotData[i].push(all);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.fill.push('All');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
PlayTones() {
|
|
193
|
+
if (Array.isArray(this.plotData[position.x][position.y])) {
|
|
194
|
+
if (constants.sonifMode == 'on') {
|
|
195
|
+
// we play a run of tones
|
|
196
|
+
position.z = 0;
|
|
197
|
+
constants.sepPlayId = setInterval(
|
|
198
|
+
function () {
|
|
199
|
+
// play this tone
|
|
200
|
+
audio.playTone();
|
|
201
|
+
|
|
202
|
+
// and then set up for the next one
|
|
203
|
+
position.z += 1;
|
|
204
|
+
|
|
205
|
+
// and kill if we're done
|
|
206
|
+
if (position.z + 1 > plot.plotData[position.x][position.y].length) {
|
|
207
|
+
constants.KillSepPlay();
|
|
208
|
+
position.z = -1;
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
constants.sonifMode == 'on' ? constants.autoPlayPointsRate : 0
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
// sonifMode == 'same', so we play all at once
|
|
215
|
+
for (let i = 0; i < this.plotData[position.x][position.y].length; i++) {
|
|
216
|
+
position.z = i;
|
|
217
|
+
audio.playTone();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
audio.playTone();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
SetMaxMin() {
|
|
226
|
+
for (let i = 0; i < singleMaidr.data.length; i++) {
|
|
227
|
+
if (i == 0) {
|
|
228
|
+
constants.maxY = singleMaidr.data[i].y;
|
|
229
|
+
constants.minY = singleMaidr.data[i].y;
|
|
230
|
+
} else {
|
|
231
|
+
if (singleMaidr.data[i].y > constants.maxY) {
|
|
232
|
+
constants.maxY = singleMaidr.data[i].y;
|
|
233
|
+
}
|
|
234
|
+
if (singleMaidr.data[i].y < constants.minY) {
|
|
235
|
+
constants.minY = singleMaidr.data[i].y;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
constants.maxX = this.level.length;
|
|
240
|
+
constants.autoPlayRate = Math.min(
|
|
241
|
+
Math.ceil(constants.AUTOPLAY_DURATION / (constants.maxX + 1)),
|
|
242
|
+
constants.MAX_SPEED
|
|
243
|
+
);
|
|
244
|
+
constants.DEFAULT_SPEED = constants.autoPlayRate;
|
|
245
|
+
if (constants.autoPlayRate < constants.MIN_SPEED) {
|
|
246
|
+
constants.MIN_SPEED = constants.autoPlayRate;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
Select() {
|
|
251
|
+
this.UnSelectPrevious();
|
|
252
|
+
if (this.elements) {
|
|
253
|
+
this.activeElement = this.elements[position.x][position.y];
|
|
254
|
+
if (this.activeElement) {
|
|
255
|
+
this.activeElementColor = this.activeElement.style.fill;
|
|
256
|
+
let newColor = constants.GetBetterColor(this.activeElementColor);
|
|
257
|
+
this.activeElement.style.fill = newColor;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
UnSelectPrevious() {
|
|
263
|
+
if (this.activeElement) {
|
|
264
|
+
this.activeElement.style.fill = this.activeElementColor;
|
|
265
|
+
this.activeElement = null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|