Skip to content

Commit 1064d74

Browse files
authored
Merge pull request #71 from sandboxnu/feature/blur-images
Add functionality to blur images for demos
2 parents 5cd8abf + 6c776e0 commit 1064d74

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

predictiveaffect.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,7 @@
144144
#jspsych-data-display {
145145
text-align: left;
146146
}
147+
148+
.img-blurred {
149+
filter: blur(30px);
150+
}

src/experiment.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const {
55
generateImageHTMLNoDot,
66
showFixationDot,
77
showIntertrialBreak,
8-
getImagePath,
98
isNegativeImg
109
} = require("./utils/imageUtils");
1110
const {
@@ -220,12 +219,12 @@ const displayTriplet = (trip, ordering) => {
220219
timeline.push(tripletInstructions);
221220

222221
for (let i = 0; i < param["imageStructLength"]; i++) {
223-
const imgPath = getImagePath(trip.getImage(i));
222+
const img = trip.getImage(i);
224223
showFixationDot(timeline);
225224

226225
const imagePrompt = {
227-
type: "image-keyboard-response",
228-
stimulus: imgPath,
226+
type: "html-keyboard-response",
227+
stimulus: generateImageHTMLNoDot(img),
229228
choices: jsPsych.NO_KEYS,
230229
trial_duration: 1000
231230
};

src/utils/imageUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const getImagePath = ({ valence, fileName }) => {
185185
*/
186186
const generateImageHTML = image => `
187187
<div class="img-overlay-wrap">
188-
<img src="${getImagePath(image)}">
188+
<img class="${param.blurImages && 'img-blurred'}" src="${getImagePath(image)}">
189189
<svg height="${param.img_y}" width="${param.img_x}">
190190
<circle cx="${image.greyDotX}" cy="${image.greyDotY}" r="${
191191
param.grey_radius
@@ -197,7 +197,7 @@ const generateImageHTML = image => `
197197
// generates image HTML like above but with no grey dot
198198
const generateImageHTMLNoDot = image => `
199199
<div class="img-overlay-wrap">
200-
<img src="${getImagePath(image)}">
200+
<img class="${param.blurImages && 'img-blurred'}" src="${getImagePath(image)}">
201201
</div>
202202
`;
203203

0 commit comments

Comments
 (0)