@m2c2kit/assessment-color-shapes 0.8.3
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/assets/color-shapes/fonts/roboto/LICENSE.txt +202 -0
- package/assets/color-shapes/fonts/roboto/Roboto-Regular.ttf +0 -0
- package/assets/color-shapes/img/circle-x.svg +3 -0
- package/assets/color-shapes/img/cs-instructions-1.png +0 -0
- package/assets/color-shapes/img/cs-instructions-2.png +0 -0
- package/assets/color-shapes/img/cs-instructions-3.png +0 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +815 -0
- package/package.json +35 -0
- package/post-install.mjs +72 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
2
|
+
<path fill= "dimgray" fill-rule="evenodd" d="M12,23 C5.92486775,23 1,18.0751322 1,12 C1,5.92486775 5.92486775,1 12,1 C18.0751322,1 23,5.92486775 23,12 C23,18.0751322 18.0751322,23 12,23 Z M12,21 C16.9705627,21 21,16.9705627 21,12 C21,7.02943725 16.9705627,3 12,3 C7.02943725,3 3,7.02943725 3,12 C3,16.9705627 7.02943725,21 12,21 Z M12,13.4142136 L8.70710678,16.7071068 L7.29289322,15.2928932 L10.5857864,12 L7.29289322,8.70710678 L8.70710678,7.29289322 L12,10.5857864 L15.2928932,7.29289322 L16.7071068,8.70710678 L13.4142136,12 L16.7071068,15.2928932 L15.2928932,16.7071068 L12,13.4142136 Z"/>
|
|
3
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import { Game, Shape, Sprite, Scene, WebColors, Transition, RandomDraws, Label, Action, Timer, TransitionDirection, Easings } from '@m2c2kit/core';
|
|
2
|
+
import { Instructions, Grid, Button } from '@m2c2kit/addons';
|
|
3
|
+
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __reflectGet = Reflect.get;
|
|
6
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
7
|
+
var __async = (__this, __arguments, generator) => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
var fulfilled = (value) => {
|
|
10
|
+
try {
|
|
11
|
+
step(generator.next(value));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
reject(e);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var rejected = (value) => {
|
|
17
|
+
try {
|
|
18
|
+
step(generator.throw(value));
|
|
19
|
+
} catch (e) {
|
|
20
|
+
reject(e);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
24
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
class ColorShapes extends Game {
|
|
28
|
+
constructor() {
|
|
29
|
+
const defaultParameters = {
|
|
30
|
+
fixation_duration_ms: {
|
|
31
|
+
default: 500,
|
|
32
|
+
description: "How long fixation scene is shown, milliseconds.",
|
|
33
|
+
type: "number"
|
|
34
|
+
},
|
|
35
|
+
shape_colors: {
|
|
36
|
+
type: "array",
|
|
37
|
+
description: "Array of colors for shapes.",
|
|
38
|
+
items: {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
colorName: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Human-friendly name of color."
|
|
44
|
+
},
|
|
45
|
+
rgbaColor: {
|
|
46
|
+
type: "array",
|
|
47
|
+
description: "Color as array, [r,g,b,a].",
|
|
48
|
+
items: {
|
|
49
|
+
type: "number"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
default: [
|
|
55
|
+
{ colorName: "black", rgbaColor: [0, 0, 0, 1] },
|
|
56
|
+
{ colorName: "green", rgbaColor: [0, 158, 115, 1] },
|
|
57
|
+
{ colorName: "yellow", rgbaColor: [240, 228, 66, 1] },
|
|
58
|
+
{ colorName: "blue", rgbaColor: [0, 114, 178, 1] },
|
|
59
|
+
{ colorName: "orange", rgbaColor: [213, 94, 0, 1] },
|
|
60
|
+
{ colorName: "pink", rgbaColor: [204, 121, 167, 1] }
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
number_of_shapes_shown: {
|
|
64
|
+
default: 3,
|
|
65
|
+
description: "How many shapes to show on the grid at one time.",
|
|
66
|
+
type: "integer"
|
|
67
|
+
},
|
|
68
|
+
shapes_presented_duration_ms: {
|
|
69
|
+
default: 2e3,
|
|
70
|
+
description: "How long the shapes are shown, milliseconds.",
|
|
71
|
+
type: "number"
|
|
72
|
+
},
|
|
73
|
+
shapes_removed_duration_ms: {
|
|
74
|
+
default: 1e3,
|
|
75
|
+
description: "How long to show a blank square after shapes are removed, milliseconds.",
|
|
76
|
+
type: "number"
|
|
77
|
+
},
|
|
78
|
+
cells_per_side: {
|
|
79
|
+
default: 3,
|
|
80
|
+
description: "How many cell positions for each side of the square grid (e.g., 3 is a 3x3 grid; 4 is a 4x4 grid).",
|
|
81
|
+
type: "integer"
|
|
82
|
+
},
|
|
83
|
+
number_of_different_colors_trials: {
|
|
84
|
+
default: 2,
|
|
85
|
+
type: "integer",
|
|
86
|
+
description: "Number of trials where the shapes have different colors. If shapes have different colors in a trial, anywhere from 2 to (number of shapes) will be given different colors."
|
|
87
|
+
},
|
|
88
|
+
number_of_trials: {
|
|
89
|
+
default: 4,
|
|
90
|
+
description: "How many trials to run.",
|
|
91
|
+
type: "integer"
|
|
92
|
+
},
|
|
93
|
+
show_trials_complete_scene: {
|
|
94
|
+
default: true,
|
|
95
|
+
type: "boolean",
|
|
96
|
+
description: "After the final trial, should a completion scene be shown? Otherwise, the game will immediately end."
|
|
97
|
+
},
|
|
98
|
+
trials_complete_scene_text: {
|
|
99
|
+
default: "You have completed all the color shapes trials",
|
|
100
|
+
description: "Text for scene displayed after all trials are complete.",
|
|
101
|
+
type: "string"
|
|
102
|
+
},
|
|
103
|
+
trials_complete_scene_button_text: {
|
|
104
|
+
default: "OK",
|
|
105
|
+
description: "Button text for scene displayed after all trials are complete.",
|
|
106
|
+
type: "string"
|
|
107
|
+
},
|
|
108
|
+
instruction_type: {
|
|
109
|
+
default: "long",
|
|
110
|
+
description: "Type of intructions to show, 'short' or 'long'.",
|
|
111
|
+
type: "string",
|
|
112
|
+
enum: ["short", "long"]
|
|
113
|
+
},
|
|
114
|
+
show_quit_button: {
|
|
115
|
+
type: "boolean",
|
|
116
|
+
default: true,
|
|
117
|
+
description: "Should the activity quit button be shown?"
|
|
118
|
+
},
|
|
119
|
+
show_fps: {
|
|
120
|
+
type: "boolean",
|
|
121
|
+
default: false,
|
|
122
|
+
description: "Should the FPS be shown?"
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const colorShapesTrialSchema = {
|
|
126
|
+
activity_begin_iso8601_timestamp: {
|
|
127
|
+
type: "string",
|
|
128
|
+
format: "date-time",
|
|
129
|
+
description: "ISO 8601 timestamp at the beginning of the game activity."
|
|
130
|
+
},
|
|
131
|
+
trial_begin_iso8601_timestamp: {
|
|
132
|
+
type: ["string", "null"],
|
|
133
|
+
format: "date-time",
|
|
134
|
+
description: "ISO 8601 timestamp at the beginning of the trial. Null if trial was skipped."
|
|
135
|
+
},
|
|
136
|
+
trial_index: {
|
|
137
|
+
type: ["integer", "null"],
|
|
138
|
+
description: "Index of the trial within this assessment, 0-based."
|
|
139
|
+
},
|
|
140
|
+
present_shapes: {
|
|
141
|
+
description: "Configuration of shapes shown to the user in the presentation phase. Null if trial was skipped.",
|
|
142
|
+
type: ["array", "null"],
|
|
143
|
+
items: {
|
|
144
|
+
type: "object",
|
|
145
|
+
properties: {
|
|
146
|
+
shape_index: {
|
|
147
|
+
type: "integer",
|
|
148
|
+
description: "Index of the shape within the library of shapes, 0-based"
|
|
149
|
+
},
|
|
150
|
+
color_name: {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "Human-friendly name of color."
|
|
153
|
+
},
|
|
154
|
+
rgba_color: {
|
|
155
|
+
type: "array",
|
|
156
|
+
description: "Color as array, [r,g,b,a].",
|
|
157
|
+
items: {
|
|
158
|
+
type: "number"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
location: {
|
|
162
|
+
type: "object",
|
|
163
|
+
description: "Location of shape.",
|
|
164
|
+
properties: {
|
|
165
|
+
row: {
|
|
166
|
+
type: "number",
|
|
167
|
+
description: "Row of the shape, 0-based."
|
|
168
|
+
},
|
|
169
|
+
column: {
|
|
170
|
+
type: "number",
|
|
171
|
+
description: "Column of the shape, 0-based."
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
response_shapes: {
|
|
179
|
+
description: "Configuration of shapes shown to the user in the response phase. Null if trial was skipped.",
|
|
180
|
+
type: ["array", "null"],
|
|
181
|
+
items: {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {
|
|
184
|
+
shape_index: {
|
|
185
|
+
type: "integer",
|
|
186
|
+
description: "Index of the shape within the library of shapes, 0-based"
|
|
187
|
+
},
|
|
188
|
+
color_name: {
|
|
189
|
+
type: "string",
|
|
190
|
+
description: "Human-friendly name of color."
|
|
191
|
+
},
|
|
192
|
+
rgba_color: {
|
|
193
|
+
type: "array",
|
|
194
|
+
description: "Color as array, [r,g,b,a].",
|
|
195
|
+
items: {
|
|
196
|
+
type: "number"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
location: {
|
|
200
|
+
type: "object",
|
|
201
|
+
description: "Location of shape.",
|
|
202
|
+
properties: {
|
|
203
|
+
row: {
|
|
204
|
+
type: "number",
|
|
205
|
+
description: "Row of the shape, 0-based."
|
|
206
|
+
},
|
|
207
|
+
column: {
|
|
208
|
+
type: "number",
|
|
209
|
+
description: "Column of the shape, 0-based."
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
number_of_different_shapes: {
|
|
217
|
+
type: ["integer", "null"],
|
|
218
|
+
description: "Number of shapes shown with different colors in the response phase."
|
|
219
|
+
},
|
|
220
|
+
response_time_duration_ms: {
|
|
221
|
+
type: ["number", "null"],
|
|
222
|
+
description: "Milliseconds from when the response configuration of shapes is shown until the user taps a response. Null if trial was skipped."
|
|
223
|
+
},
|
|
224
|
+
user_response: {
|
|
225
|
+
type: ["string", "null"],
|
|
226
|
+
enum: ["same", "different"],
|
|
227
|
+
description: "User's response to whether the shapes are same colors or different."
|
|
228
|
+
},
|
|
229
|
+
user_response_correct: {
|
|
230
|
+
type: ["boolean", "null"],
|
|
231
|
+
description: "Was the user's response correct?"
|
|
232
|
+
},
|
|
233
|
+
quit_button_pressed: {
|
|
234
|
+
type: "boolean",
|
|
235
|
+
description: "Was the quit button pressed?"
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const options = {
|
|
239
|
+
name: "Color Shapes",
|
|
240
|
+
id: "color-shapes",
|
|
241
|
+
version: "0.8.3",
|
|
242
|
+
shortDescription: "Color Shapes is a visual array change detection task, measuring intra-item feature binding, where participants determine if shapes change color across two sequential presentations of shape stimuli.",
|
|
243
|
+
longDescription: `Color Shapes is a change detection paradigm used to measure visual short-term memory binding (Parra et al., 2009). Participants are asked to memorize the shapes and colors of three different polygons for 3 seconds. The three polygons are then removed from the screen and re-displayed at different locations, either having the same or different colors. Participants are then asked to decide whether the combination of colors and shapes are the "Same" or "Different" between the study and test phases.`,
|
|
244
|
+
showFps: defaultParameters.show_fps.default,
|
|
245
|
+
width: 400,
|
|
246
|
+
height: 800,
|
|
247
|
+
trialSchema: colorShapesTrialSchema,
|
|
248
|
+
parameters: defaultParameters,
|
|
249
|
+
fontUrls: ["assets/color-shapes/fonts/roboto/Roboto-Regular.ttf"],
|
|
250
|
+
images: [
|
|
251
|
+
{
|
|
252
|
+
imageName: "instructions-1",
|
|
253
|
+
height: 256,
|
|
254
|
+
width: 256,
|
|
255
|
+
url: "assets/color-shapes/img/cs-instructions-1.png"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
imageName: "instructions-2",
|
|
259
|
+
height: 256,
|
|
260
|
+
width: 256,
|
|
261
|
+
url: "assets/color-shapes/img/cs-instructions-2.png"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
imageName: "instructions-3",
|
|
265
|
+
height: 330,
|
|
266
|
+
width: 256,
|
|
267
|
+
url: "assets/color-shapes/img/cs-instructions-3.png"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
imageName: "circle-x",
|
|
271
|
+
height: 32,
|
|
272
|
+
width: 32,
|
|
273
|
+
// the svg is from evericons and is licensed under CC0 1.0
|
|
274
|
+
// Universal (Public Domain). see https://www.patreon.com/evericons
|
|
275
|
+
url: "assets/color-shapes/img/circle-x.svg"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
};
|
|
279
|
+
super(options);
|
|
280
|
+
}
|
|
281
|
+
init() {
|
|
282
|
+
return __async(this, null, function* () {
|
|
283
|
+
yield __superGet(ColorShapes.prototype, this, "init").call(this);
|
|
284
|
+
const game = this;
|
|
285
|
+
const SHAPE_SVG_HEIGHT = 96;
|
|
286
|
+
const SQUARE_SIDE_LENGTH = 350;
|
|
287
|
+
const SHAPE_SIZE = { width: 116, height: 116 };
|
|
288
|
+
const numberOfShapesShown = game.getParameter(
|
|
289
|
+
"number_of_shapes_shown"
|
|
290
|
+
);
|
|
291
|
+
const shapeLibrary = this.makeShapes(SHAPE_SVG_HEIGHT, SHAPE_SIZE);
|
|
292
|
+
if (game.getParameter("show_quit_button")) {
|
|
293
|
+
const quitSprite = new Sprite({
|
|
294
|
+
imageName: "circle-x",
|
|
295
|
+
position: { x: 380, y: 20 },
|
|
296
|
+
isUserInteractionEnabled: true
|
|
297
|
+
});
|
|
298
|
+
game.addFreeEntity(quitSprite);
|
|
299
|
+
quitSprite.onTapDown((e) => {
|
|
300
|
+
game.removeAllFreeEntities();
|
|
301
|
+
e.handled = true;
|
|
302
|
+
const blankScene = new Scene();
|
|
303
|
+
game.addScene(blankScene);
|
|
304
|
+
game.presentScene(blankScene);
|
|
305
|
+
game.addTrialData("quit_button_pressed", true);
|
|
306
|
+
game.trialComplete();
|
|
307
|
+
game.cancel();
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
let instructionsScenes;
|
|
311
|
+
switch (game.getParameter("instruction_type")) {
|
|
312
|
+
case "short": {
|
|
313
|
+
instructionsScenes = Instructions.Create({
|
|
314
|
+
instructionScenes: [
|
|
315
|
+
{
|
|
316
|
+
title: "Color Shapes",
|
|
317
|
+
text: `Try to remember the location and color of ${numberOfShapesShown} shapes, because they will soon disappear. When the shapes reappear, answer whether they have the SAME or DIFFERENT colors as they had before.`,
|
|
318
|
+
imageName: "instructions-1",
|
|
319
|
+
imageAboveText: false,
|
|
320
|
+
imageMarginTop: 32,
|
|
321
|
+
textFontSize: 24,
|
|
322
|
+
titleFontSize: 30,
|
|
323
|
+
textVerticalBias: 0.2,
|
|
324
|
+
nextButtonText: "START",
|
|
325
|
+
nextButtonBackgroundColor: WebColors.Green,
|
|
326
|
+
nextSceneTransition: Transition.none()
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
});
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case "long": {
|
|
333
|
+
instructionsScenes = Instructions.Create({
|
|
334
|
+
instructionScenes: [
|
|
335
|
+
{
|
|
336
|
+
title: "Color Shapes",
|
|
337
|
+
text: `Try to remember the location and color of ${numberOfShapesShown} shapes, because they will soon disappear.`,
|
|
338
|
+
imageName: "instructions-1",
|
|
339
|
+
imageAboveText: false,
|
|
340
|
+
imageMarginTop: 32,
|
|
341
|
+
textFontSize: 24,
|
|
342
|
+
titleFontSize: 30,
|
|
343
|
+
textVerticalBias: 0.2
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
title: "Color Shapes",
|
|
347
|
+
text: "Next you will see the same shapes reappear.",
|
|
348
|
+
imageName: "instructions-2",
|
|
349
|
+
imageAboveText: false,
|
|
350
|
+
imageMarginTop: 32,
|
|
351
|
+
textFontSize: 24,
|
|
352
|
+
titleFontSize: 30,
|
|
353
|
+
textVerticalBias: 0.2
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
title: "Color Shapes",
|
|
357
|
+
text: "Answer whether the shapes have the SAME or DIFFERENT colors as they had before.",
|
|
358
|
+
imageName: "instructions-3",
|
|
359
|
+
imageAboveText: false,
|
|
360
|
+
imageMarginTop: 32,
|
|
361
|
+
textFontSize: 24,
|
|
362
|
+
titleFontSize: 30,
|
|
363
|
+
textVerticalBias: 0.2,
|
|
364
|
+
nextButtonText: "START",
|
|
365
|
+
nextButtonBackgroundColor: WebColors.Green,
|
|
366
|
+
nextSceneTransition: Transition.none()
|
|
367
|
+
}
|
|
368
|
+
]
|
|
369
|
+
});
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
default: {
|
|
373
|
+
throw new Error("invalid value for instruction_type");
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
instructionsScenes[0].onAppear(() => {
|
|
377
|
+
game.addTrialData(
|
|
378
|
+
"activity_begin_iso8601_timestamp",
|
|
379
|
+
this.beginIso8601Timestamp
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
game.addScenes(instructionsScenes);
|
|
383
|
+
const gridRows = game.getParameter("cells_per_side");
|
|
384
|
+
const gridColumns = game.getParameter("cells_per_side");
|
|
385
|
+
const numberOfTrials = game.getParameter("number_of_trials");
|
|
386
|
+
const shapeColors = game.getParameter(
|
|
387
|
+
"shape_colors"
|
|
388
|
+
);
|
|
389
|
+
const trialConfigurations = [];
|
|
390
|
+
const rows = game.getParameter("cells_per_side");
|
|
391
|
+
const columns = rows;
|
|
392
|
+
const numberOfDifferentColorsTrials = game.getParameter(
|
|
393
|
+
"number_of_different_colors_trials"
|
|
394
|
+
);
|
|
395
|
+
const differentColorsTrialIndexes = RandomDraws.FromRangeWithoutReplacement(
|
|
396
|
+
numberOfDifferentColorsTrials,
|
|
397
|
+
0,
|
|
398
|
+
numberOfTrials - 1
|
|
399
|
+
);
|
|
400
|
+
for (let i = 0; i < numberOfTrials; i++) {
|
|
401
|
+
const presentShapes = new Array();
|
|
402
|
+
const responseShapes = new Array();
|
|
403
|
+
const shapesToShowIndexes = RandomDraws.FromRangeWithoutReplacement(
|
|
404
|
+
numberOfShapesShown,
|
|
405
|
+
0,
|
|
406
|
+
shapeLibrary.length - 1
|
|
407
|
+
);
|
|
408
|
+
const shapeColorsIndexes = RandomDraws.FromRangeWithoutReplacement(
|
|
409
|
+
numberOfShapesShown,
|
|
410
|
+
0,
|
|
411
|
+
shapeColors.length - 1
|
|
412
|
+
);
|
|
413
|
+
const onDiagonal = (locations) => {
|
|
414
|
+
if (locations.map((c) => c.row === 0 && c.column === 0).some((e) => e === true) && locations.map((c) => c.row === 1 && c.column === 1).some((e) => e === true) && locations.map((c) => c.row === 2 && c.column === 2).some((e) => e === true)) {
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
if (locations.map((c) => c.row === 2 && c.column === 0).some((e) => e === true) && locations.map((c) => c.row === 1 && c.column === 1).some((e) => e === true) && locations.map((c) => c.row === 0 && c.column === 2).some((e) => e === true)) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
return false;
|
|
421
|
+
};
|
|
422
|
+
const inLine = (locations) => {
|
|
423
|
+
const uniqueRows = new Set(locations.map((l) => l.row)).size;
|
|
424
|
+
const uniqueColumns = new Set(locations.map((l) => l.column)).size;
|
|
425
|
+
if (uniqueRows !== 1 && uniqueColumns !== 1) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
};
|
|
430
|
+
let presentLocationsOk = false;
|
|
431
|
+
let presentLocations;
|
|
432
|
+
do {
|
|
433
|
+
presentLocations = RandomDraws.FromGridWithoutReplacement(
|
|
434
|
+
numberOfShapesShown,
|
|
435
|
+
rows,
|
|
436
|
+
columns
|
|
437
|
+
);
|
|
438
|
+
if (!inLine(presentLocations) && !onDiagonal(presentLocations)) {
|
|
439
|
+
presentLocationsOk = true;
|
|
440
|
+
} else {
|
|
441
|
+
presentLocationsOk = false;
|
|
442
|
+
}
|
|
443
|
+
} while (!presentLocationsOk);
|
|
444
|
+
for (let j = 0; j < numberOfShapesShown; j++) {
|
|
445
|
+
const presentShape = {
|
|
446
|
+
shape: shapeLibrary[shapesToShowIndexes[j]],
|
|
447
|
+
shapeIndex: shapesToShowIndexes[j],
|
|
448
|
+
color: shapeColors[shapeColorsIndexes[j]].rgbaColor,
|
|
449
|
+
colorName: shapeColors[shapeColorsIndexes[j]].colorName,
|
|
450
|
+
location: presentLocations[j]
|
|
451
|
+
};
|
|
452
|
+
presentShapes.push(presentShape);
|
|
453
|
+
}
|
|
454
|
+
let responseLocationsOk = false;
|
|
455
|
+
let responseLocations;
|
|
456
|
+
do {
|
|
457
|
+
responseLocations = RandomDraws.FromGridWithoutReplacement(
|
|
458
|
+
numberOfShapesShown,
|
|
459
|
+
rows,
|
|
460
|
+
columns
|
|
461
|
+
);
|
|
462
|
+
if (!inLine(responseLocations) && !onDiagonal(responseLocations)) {
|
|
463
|
+
responseLocationsOk = true;
|
|
464
|
+
} else {
|
|
465
|
+
responseLocationsOk = false;
|
|
466
|
+
}
|
|
467
|
+
} while (!responseLocationsOk);
|
|
468
|
+
for (let j = 0; j < numberOfShapesShown; j++) {
|
|
469
|
+
const responseShape = {
|
|
470
|
+
shape: presentShapes[j].shape,
|
|
471
|
+
shapeIndex: shapesToShowIndexes[j],
|
|
472
|
+
color: presentShapes[j].color,
|
|
473
|
+
colorName: shapeColors[shapeColorsIndexes[j]].colorName,
|
|
474
|
+
location: responseLocations[j]
|
|
475
|
+
};
|
|
476
|
+
responseShapes.push(responseShape);
|
|
477
|
+
}
|
|
478
|
+
let numberOfShapesWithDifferentColors = 0;
|
|
479
|
+
const differentColorTrial = differentColorsTrialIndexes.includes(i);
|
|
480
|
+
if (differentColorTrial) {
|
|
481
|
+
const numberOfShapesToChange = RandomDraws.SingleFromRange(
|
|
482
|
+
2,
|
|
483
|
+
numberOfShapesShown
|
|
484
|
+
);
|
|
485
|
+
const shapesToChangeIndexes = RandomDraws.FromRangeWithoutReplacement(
|
|
486
|
+
numberOfShapesToChange,
|
|
487
|
+
0,
|
|
488
|
+
numberOfShapesShown - 1
|
|
489
|
+
);
|
|
490
|
+
const shapesToChange = shapesToChangeIndexes.map(
|
|
491
|
+
(index) => responseShapes[index]
|
|
492
|
+
);
|
|
493
|
+
numberOfShapesWithDifferentColors = shapesToChange.length;
|
|
494
|
+
const firstShapeColor = shapesToChange[0].color;
|
|
495
|
+
for (let j = 0; j < numberOfShapesToChange; j++) {
|
|
496
|
+
const shape = shapesToChange[j];
|
|
497
|
+
if (j + 1 < numberOfShapesToChange) {
|
|
498
|
+
shape.color = shapesToChange[j + 1].color;
|
|
499
|
+
} else {
|
|
500
|
+
shape.color = firstShapeColor;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
trialConfigurations.push({
|
|
505
|
+
presentShapes,
|
|
506
|
+
responseShapes,
|
|
507
|
+
numberOfShapesWithDifferentColors
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
const fixationScene = new Scene();
|
|
511
|
+
game.addScene(fixationScene);
|
|
512
|
+
const fixationSceneSquare = new Shape({
|
|
513
|
+
rect: { size: { width: SQUARE_SIDE_LENGTH, height: SQUARE_SIDE_LENGTH } },
|
|
514
|
+
fillColor: WebColors.Transparent,
|
|
515
|
+
strokeColor: WebColors.Gray,
|
|
516
|
+
lineWidth: 4,
|
|
517
|
+
position: { x: 200, y: 300 }
|
|
518
|
+
});
|
|
519
|
+
fixationScene.addChild(fixationSceneSquare);
|
|
520
|
+
const plusLabel = new Label({
|
|
521
|
+
text: "+",
|
|
522
|
+
fontSize: 32,
|
|
523
|
+
fontColor: WebColors.Black
|
|
524
|
+
});
|
|
525
|
+
fixationSceneSquare.addChild(plusLabel);
|
|
526
|
+
fixationScene.onAppear(() => {
|
|
527
|
+
game.addTrialData(
|
|
528
|
+
"activity_begin_iso8601_timestamp",
|
|
529
|
+
this.beginIso8601Timestamp
|
|
530
|
+
);
|
|
531
|
+
game.addTrialData(
|
|
532
|
+
"trial_begin_iso8601_timestamp",
|
|
533
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
534
|
+
);
|
|
535
|
+
fixationScene.run(
|
|
536
|
+
Action.sequence([
|
|
537
|
+
Action.wait({ duration: game.getParameter("fixation_duration_ms") }),
|
|
538
|
+
Action.custom({
|
|
539
|
+
callback: () => {
|
|
540
|
+
game.presentScene(shapePresentationScene);
|
|
541
|
+
}
|
|
542
|
+
})
|
|
543
|
+
])
|
|
544
|
+
);
|
|
545
|
+
});
|
|
546
|
+
const shapePresentationScene = new Scene();
|
|
547
|
+
game.addScene(shapePresentationScene);
|
|
548
|
+
const presentationSceneSquare = new Shape({
|
|
549
|
+
rect: { size: { width: SQUARE_SIDE_LENGTH, height: SQUARE_SIDE_LENGTH } },
|
|
550
|
+
fillColor: WebColors.Transparent,
|
|
551
|
+
strokeColor: WebColors.Gray,
|
|
552
|
+
lineWidth: 4,
|
|
553
|
+
position: { x: 200, y: 300 }
|
|
554
|
+
});
|
|
555
|
+
shapePresentationScene.addChild(presentationSceneSquare);
|
|
556
|
+
const presentationGrid = new Grid({
|
|
557
|
+
rows: gridRows,
|
|
558
|
+
columns: gridColumns,
|
|
559
|
+
size: { width: SQUARE_SIDE_LENGTH, height: SQUARE_SIDE_LENGTH },
|
|
560
|
+
position: { x: 200, y: 300 },
|
|
561
|
+
backgroundColor: WebColors.Transparent,
|
|
562
|
+
gridLineColor: WebColors.Transparent
|
|
563
|
+
});
|
|
564
|
+
shapePresentationScene.addChild(presentationGrid);
|
|
565
|
+
shapePresentationScene.onAppear(() => {
|
|
566
|
+
const trialConfiguration = trialConfigurations[game.trialIndex];
|
|
567
|
+
for (let i = 0; i < trialConfiguration.presentShapes.length; i++) {
|
|
568
|
+
const presentShape = trialConfiguration.presentShapes[i].shape;
|
|
569
|
+
presentShape.fillColor = trialConfiguration.presentShapes[i].color;
|
|
570
|
+
presentationGrid.addAtCell(
|
|
571
|
+
presentShape,
|
|
572
|
+
trialConfiguration.presentShapes[i].location.row,
|
|
573
|
+
trialConfiguration.presentShapes[i].location.column
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
shapePresentationScene.run(
|
|
577
|
+
Action.sequence([
|
|
578
|
+
Action.wait({
|
|
579
|
+
duration: game.getParameter("shapes_presented_duration_ms")
|
|
580
|
+
}),
|
|
581
|
+
Action.custom({
|
|
582
|
+
callback: () => {
|
|
583
|
+
presentationGrid.removeAllChildren();
|
|
584
|
+
}
|
|
585
|
+
}),
|
|
586
|
+
Action.wait({
|
|
587
|
+
duration: game.getParameter("shapes_removed_duration_ms")
|
|
588
|
+
}),
|
|
589
|
+
Action.custom({
|
|
590
|
+
callback: () => {
|
|
591
|
+
presentationGrid.removeAllChildren();
|
|
592
|
+
game.presentScene(shapeResponseScene);
|
|
593
|
+
}
|
|
594
|
+
})
|
|
595
|
+
])
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
const shapeResponseScene = new Scene();
|
|
599
|
+
game.addScene(shapeResponseScene);
|
|
600
|
+
const responseSceneSquare = new Shape({
|
|
601
|
+
rect: { size: { width: SQUARE_SIDE_LENGTH, height: SQUARE_SIDE_LENGTH } },
|
|
602
|
+
fillColor: WebColors.Transparent,
|
|
603
|
+
strokeColor: WebColors.Gray,
|
|
604
|
+
lineWidth: 4,
|
|
605
|
+
position: { x: 200, y: 300 }
|
|
606
|
+
});
|
|
607
|
+
shapeResponseScene.addChild(responseSceneSquare);
|
|
608
|
+
const responseGrid = new Grid({
|
|
609
|
+
rows: gridRows,
|
|
610
|
+
columns: gridColumns,
|
|
611
|
+
size: { width: SQUARE_SIDE_LENGTH, height: SQUARE_SIDE_LENGTH },
|
|
612
|
+
position: { x: 200, y: 300 },
|
|
613
|
+
backgroundColor: WebColors.Transparent,
|
|
614
|
+
gridLineColor: WebColors.Transparent
|
|
615
|
+
});
|
|
616
|
+
shapeResponseScene.addChild(responseGrid);
|
|
617
|
+
shapeResponseScene.onAppear(() => {
|
|
618
|
+
const trialConfiguration = trialConfigurations[game.trialIndex];
|
|
619
|
+
for (let i = 0; i < trialConfiguration.responseShapes.length; i++) {
|
|
620
|
+
const responseShape = trialConfiguration.responseShapes[i].shape;
|
|
621
|
+
responseShape.fillColor = trialConfiguration.responseShapes[i].color;
|
|
622
|
+
responseGrid.addAtCell(
|
|
623
|
+
responseShape,
|
|
624
|
+
trialConfiguration.responseShapes[i].location.row,
|
|
625
|
+
trialConfiguration.responseShapes[i].location.column
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
sameButton.isUserInteractionEnabled = true;
|
|
629
|
+
differentButton.isUserInteractionEnabled = true;
|
|
630
|
+
Timer.start("rt");
|
|
631
|
+
});
|
|
632
|
+
const sameButton = new Button({
|
|
633
|
+
text: "Same",
|
|
634
|
+
position: { x: 100, y: 700 },
|
|
635
|
+
size: { width: 125, height: 50 }
|
|
636
|
+
});
|
|
637
|
+
shapeResponseScene.addChild(sameButton);
|
|
638
|
+
sameButton.onTapDown(() => {
|
|
639
|
+
sameButton.isUserInteractionEnabled = false;
|
|
640
|
+
handleSelection(false);
|
|
641
|
+
});
|
|
642
|
+
const differentButton = new Button({
|
|
643
|
+
text: "Different",
|
|
644
|
+
position: { x: 300, y: 700 },
|
|
645
|
+
size: { width: 125, height: 50 }
|
|
646
|
+
});
|
|
647
|
+
shapeResponseScene.addChild(differentButton);
|
|
648
|
+
differentButton.onTapDown(() => {
|
|
649
|
+
differentButton.isUserInteractionEnabled = false;
|
|
650
|
+
handleSelection(true);
|
|
651
|
+
});
|
|
652
|
+
const handleSelection = (differentPressed) => {
|
|
653
|
+
const rt = Timer.elapsed("rt");
|
|
654
|
+
Timer.remove("rt");
|
|
655
|
+
responseGrid.removeAllChildren();
|
|
656
|
+
const trialConfiguration = trialConfigurations[game.trialIndex];
|
|
657
|
+
game.addTrialData("response_time_duration_ms", rt);
|
|
658
|
+
game.addTrialData(
|
|
659
|
+
"number_of_different_shapes",
|
|
660
|
+
trialConfiguration.numberOfShapesWithDifferentColors
|
|
661
|
+
);
|
|
662
|
+
game.addTrialData(
|
|
663
|
+
"user_response",
|
|
664
|
+
differentPressed ? "different" : "same"
|
|
665
|
+
);
|
|
666
|
+
const correctResponse = trialConfiguration.numberOfShapesWithDifferentColors === 0 && !differentPressed || trialConfiguration.numberOfShapesWithDifferentColors > 0 && differentPressed;
|
|
667
|
+
game.addTrialData("user_response_correct", correctResponse);
|
|
668
|
+
const presentShapes = trialConfiguration.presentShapes.map((p) => {
|
|
669
|
+
return {
|
|
670
|
+
shape_index: p.shapeIndex,
|
|
671
|
+
color_name: p.colorName,
|
|
672
|
+
rgba_color: p.color,
|
|
673
|
+
location: p.location
|
|
674
|
+
};
|
|
675
|
+
});
|
|
676
|
+
game.addTrialData("present_shapes", presentShapes);
|
|
677
|
+
game.addTrialData("quit_button_pressed", false);
|
|
678
|
+
const responseShapes = trialConfiguration.responseShapes.map((p) => {
|
|
679
|
+
return {
|
|
680
|
+
shape_index: p.shapeIndex,
|
|
681
|
+
color_name: p.colorName,
|
|
682
|
+
rgba_color: p.color,
|
|
683
|
+
location: p.location
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
game.addTrialData("response_shapes", responseShapes);
|
|
687
|
+
game.addTrialData("trial_index", game.trialIndex);
|
|
688
|
+
game.trialComplete();
|
|
689
|
+
if (game.trialIndex < numberOfTrials) {
|
|
690
|
+
game.presentScene(fixationScene);
|
|
691
|
+
} else {
|
|
692
|
+
game.presentScene(
|
|
693
|
+
doneScene,
|
|
694
|
+
Transition.slide({
|
|
695
|
+
direction: TransitionDirection.Left,
|
|
696
|
+
duration: 500,
|
|
697
|
+
easing: Easings.sinusoidalInOut
|
|
698
|
+
})
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
const doneScene = new Scene();
|
|
703
|
+
game.addScene(doneScene);
|
|
704
|
+
const doneSceneText = new Label({
|
|
705
|
+
text: game.getParameter("trials_complete_scene_text"),
|
|
706
|
+
position: { x: 200, y: 400 }
|
|
707
|
+
});
|
|
708
|
+
doneScene.addChild(doneSceneText);
|
|
709
|
+
const okButton = new Button({
|
|
710
|
+
text: game.getParameter("trials_complete_scene_button_text"),
|
|
711
|
+
position: { x: 200, y: 650 }
|
|
712
|
+
});
|
|
713
|
+
okButton.isUserInteractionEnabled = true;
|
|
714
|
+
okButton.onTapDown(() => {
|
|
715
|
+
okButton.isUserInteractionEnabled = false;
|
|
716
|
+
doneScene.removeAllChildren();
|
|
717
|
+
game.end();
|
|
718
|
+
});
|
|
719
|
+
doneScene.addChild(okButton);
|
|
720
|
+
doneScene.onSetup(() => {
|
|
721
|
+
game.removeAllFreeEntities();
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
makeShapes(svgHeight, size) {
|
|
726
|
+
const shape01 = new Shape({
|
|
727
|
+
path: {
|
|
728
|
+
svgString: shapePathSvgStrings[0],
|
|
729
|
+
height: svgHeight
|
|
730
|
+
},
|
|
731
|
+
size,
|
|
732
|
+
lineWidth: 0
|
|
733
|
+
});
|
|
734
|
+
const shape02 = new Shape({
|
|
735
|
+
path: {
|
|
736
|
+
svgString: shapePathSvgStrings[1],
|
|
737
|
+
height: svgHeight
|
|
738
|
+
},
|
|
739
|
+
size,
|
|
740
|
+
lineWidth: 0
|
|
741
|
+
});
|
|
742
|
+
const shape03 = new Shape({
|
|
743
|
+
path: {
|
|
744
|
+
svgString: shapePathSvgStrings[2],
|
|
745
|
+
height: svgHeight * 0.8
|
|
746
|
+
},
|
|
747
|
+
size,
|
|
748
|
+
lineWidth: 0
|
|
749
|
+
});
|
|
750
|
+
const shape04 = new Shape({
|
|
751
|
+
path: {
|
|
752
|
+
svgString: shapePathSvgStrings[3],
|
|
753
|
+
height: svgHeight
|
|
754
|
+
},
|
|
755
|
+
size,
|
|
756
|
+
lineWidth: 0
|
|
757
|
+
});
|
|
758
|
+
const shape05 = new Shape({
|
|
759
|
+
path: {
|
|
760
|
+
svgString: shapePathSvgStrings[4],
|
|
761
|
+
height: svgHeight * 0.8
|
|
762
|
+
},
|
|
763
|
+
size,
|
|
764
|
+
lineWidth: 0
|
|
765
|
+
});
|
|
766
|
+
const shape06 = new Shape({
|
|
767
|
+
path: {
|
|
768
|
+
svgString: shapePathSvgStrings[5],
|
|
769
|
+
height: svgHeight
|
|
770
|
+
},
|
|
771
|
+
size,
|
|
772
|
+
lineWidth: 0
|
|
773
|
+
});
|
|
774
|
+
const shape07 = new Shape({
|
|
775
|
+
path: {
|
|
776
|
+
svgString: shapePathSvgStrings[6],
|
|
777
|
+
height: svgHeight
|
|
778
|
+
},
|
|
779
|
+
size,
|
|
780
|
+
lineWidth: 0
|
|
781
|
+
});
|
|
782
|
+
const shape08 = new Shape({
|
|
783
|
+
path: {
|
|
784
|
+
svgString: shapePathSvgStrings[7],
|
|
785
|
+
height: svgHeight
|
|
786
|
+
},
|
|
787
|
+
size,
|
|
788
|
+
lineWidth: 0
|
|
789
|
+
});
|
|
790
|
+
const shapes = [
|
|
791
|
+
shape01,
|
|
792
|
+
shape02,
|
|
793
|
+
shape03,
|
|
794
|
+
shape04,
|
|
795
|
+
shape05,
|
|
796
|
+
shape06,
|
|
797
|
+
shape07,
|
|
798
|
+
shape08
|
|
799
|
+
];
|
|
800
|
+
return shapes;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const shapePathSvgStrings = [
|
|
804
|
+
"M0 89.94v-2L131.95 0h2v88.7c2.34 1.6 4.47 3.11 6.65 4.55 42.77 28.22 85.54 56.42 128.3 84.63v2c-44.65 29.65-89.3 59.29-133.95 88.94h-1v-90.84C89.44 148.72 44.72 119.33 0 89.94Z",
|
|
805
|
+
"M162 188c-.33 27-.67 54-1 81-26.87-26.18-53.74-52.35-80-77.94V269H0C0 180.83 0 92.67.04 4.5.04 3 .67 1.5 1 0c24.64 29.1 49.15 58.31 73.96 87.26 28.88 33.7 58.01 67.17 87.04 100.74Z",
|
|
806
|
+
"M3 148.86V61.12C41.76 40.75 80.52 20.37 119.28 0h2.91c21.32 20.7 42.64 41.4 63.96 62.11v89.71c-38.44 20.04-76.88 40.09-115.31 60.13h-2.91L3.01 148.86Z",
|
|
807
|
+
"M134 0h2c7.26 22.31 14.38 44.67 21.86 66.9 3.91 11.61 5.47 29.91 13.25 33.27C203 113.94 236.86 123.13 270 134v1L136 269h-1c-11.04-33.58-22.08-67.16-33.21-101.03C67.87 156.98 33.93 145.99 0 135v-1L134 0Z",
|
|
808
|
+
"M107 0h1l108 108v1c-26.67 35.33-53.33 70.66-80 106h-1c-8.82-35.03-17.64-70.07-27-107.28C98.62 145.01 89.81 180 81.01 215h-1C53.33 179.66 26.67 144.33 0 109v-2L107 0Z",
|
|
809
|
+
"M0 1C2.17.67 4.33.05 6.5.04 58.33-.01 110.17 0 162 0v270H2c26.2-22.17 52.41-44.33 78.86-66.71V67.4c-3.85-3.22-7.35-6.2-10.9-9.11C46.64 39.18 23.32 20.09 0 1Z",
|
|
810
|
+
"M95 268.99h-1C62.66 238.66 31.33 208.33 0 178V88C26.67 58.67 53.33 29.33 80 0h1c0 29.45 0 58.89-.01 88.38 35.99 29.57 72 59.09 108.01 88.61v1l-94 91Z",
|
|
811
|
+
"M13 0h67l135 135v1L81 270c-27-.33-54-.67-81-1 11.73-12.51 23.61-24.87 35.16-37.54 33.14-36.35 66.14-72.82 100.23-110.38C94.4 80.52 53.7 40.26 13 0Z"
|
|
812
|
+
];
|
|
813
|
+
|
|
814
|
+
export { ColorShapes };
|
|
815
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@m2c2kit/assessment-color-shapes",
|
|
3
|
+
"version": "0.8.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "npm run clean && tsc && rollup -c",
|
|
6
|
+
"clean": "rimraf build build-nobundler dist .rollup.cache tsconfig.tsbuildinfo",
|
|
7
|
+
"postinstall": "node post-install.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"module": "dist/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/index.js",
|
|
18
|
+
"dist/index.d.ts",
|
|
19
|
+
"assets/**",
|
|
20
|
+
"post-install.mjs"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@m2c2kit/addons": "0.3.2",
|
|
24
|
+
"@m2c2kit/core": "0.3.5"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rollup/plugin-node-resolve": "15.0.2",
|
|
28
|
+
"@rollup/plugin-replace": "5.0.2",
|
|
29
|
+
"rimraf": "5.0.0",
|
|
30
|
+
"rollup": "3.20.6",
|
|
31
|
+
"rollup-plugin-copy": "3.4.0",
|
|
32
|
+
"rollup-plugin-esbuild": "5.0.0",
|
|
33
|
+
"typescript": "5.0.4"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/post-install.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, existsSync } from "fs";
|
|
3
|
+
import { resolve, join, dirname } from "path";
|
|
4
|
+
import { env, exit } from "process";
|
|
5
|
+
import { readdir, readFile, mkdir, writeFile } from "fs/promises";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Our current working directory for this postinstall script is the
|
|
9
|
+
* package's root folder in node_modules, e.g., node_modules/{packageName}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The folder in which npm command was executed -- this differs from the
|
|
14
|
+
* current working directory.
|
|
15
|
+
*/
|
|
16
|
+
const npmCwd = env.INIT_CWD;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* If the full m2c2kit repo has been cloned and "npm install" is executed,
|
|
20
|
+
* when this package is installed it will run this post-install script.
|
|
21
|
+
* But, we should run this only when the package is being installed in a
|
|
22
|
+
* new m2c2kit project, because it will copy assets to the
|
|
23
|
+
* appropriate location in the project root. The below code will check if
|
|
24
|
+
* npm install is being run on the entire m2c2kit repo, and if so, exit this
|
|
25
|
+
* script before copying any assets.
|
|
26
|
+
* Note: this will cause problems if someone decides to name their m2c2kit
|
|
27
|
+
* project "m2c2kit".
|
|
28
|
+
*/
|
|
29
|
+
const { name } = JSON.parse(readFileSync(join(npmCwd, "package.json")));
|
|
30
|
+
if (name === "m2c2kit") {
|
|
31
|
+
exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function copyFolderRecursive(options) {
|
|
35
|
+
async function getFilePathsRecursive(dir) {
|
|
36
|
+
const dirents = await readdir(dir, { withFileTypes: true });
|
|
37
|
+
const files = await Promise.all(
|
|
38
|
+
dirents.map((dirent) => {
|
|
39
|
+
const res = resolve(dir, dirent.name);
|
|
40
|
+
return dirent.isDirectory() ? getFilePathsRecursive(res) : res;
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
return Array.prototype.concat(...files);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const filePaths = await getFilePathsRecursive(options.sourceFolder);
|
|
47
|
+
|
|
48
|
+
filePaths.forEach(async (filePath) => {
|
|
49
|
+
const destinationFilePath = join(
|
|
50
|
+
options.destinationFolder,
|
|
51
|
+
filePath.replace(resolve(options.sourceFolder), options.baseFolder)
|
|
52
|
+
);
|
|
53
|
+
if (!options.overwrite && existsSync(destinationFilePath)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const folder = dirname(destinationFilePath);
|
|
58
|
+
if (!existsSync(folder)) {
|
|
59
|
+
await mkdir(folder, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const content = await readFile(filePath);
|
|
63
|
+
await writeFile(destinationFilePath, content);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
copyFolderRecursive({
|
|
68
|
+
sourceFolder: "assets",
|
|
69
|
+
destinationFolder: join(npmCwd, "src"),
|
|
70
|
+
baseFolder: "assets",
|
|
71
|
+
overwrite: false,
|
|
72
|
+
});
|