xxxxxxxxxx
122
let txt = {
w: 0,
y: 0,
box: 0,
}
let imm = {
h: 807 / 2,
w: 1974 / 2,
num: 2,
}
let margin = 20;
let i = 1;
let inp;
let word = "";
let font;
let readyBoolean = false;
let timer = 5;
let on = 0;
let imagecounter = 0;
let button;
// let explanation1 = 'You will be asked to fill the box underneath in ___ seconds'
let explanation2 = '1. You will see an image for a couple of seconds.'
let explanation3 = '2. You will see a blank screen.'
let explanation4 = '3. You will be asked what you think the image that was shown is.';
function preload() {
img1 = loadImage('Most Abstract.png');
img2 = loadImage('Abstract.png');
img3 = loadImage('Bit abstract.png');
img4 = loadImage('Original.jpeg')
}
function setup() {
createCanvas(256 * 4, 160 * 4);
}
function draw() {
if (timer > 0) {
if (frameCount % 60 == 0) {
timer--;
}
background(255, 255, 255);
//--------------------------------------starting point
textStyle(NORMAL);
textSize(200);
text(timer, imm.w / 2 - 100, margin + 250);
}
//--------------------------------------timer to zero = image
if (timer <= 0) {
if (frameCount % 20 == 0) {
timer--;
}
background(255, 255, 255);
if(imagecounter==0){
image(img1, 0, 0, 2388 / 4, 1668 / 4); //imm.w, imm.h);
}
else if(imagecounter==1){
image(img2, 0, 0, 2388 / 4, 1668 / 4); //imm.w, imm.h);
}
else if(imagecounter==2){
image(img3, 0, 0, 2388 / 4, 1668 / 4); //imm.w, imm.h);
}
else if(imagecounter==3){
image(img4, 0, 0, 2388 / 4, 1668 / 4); //imm.w, imm.h);
}
}
//--------------------------------------code chart
if (timer < -2) {
// image(num, margin, margin, imm.w, imm.h);
background(255, 255, 255);
}
//--------------------------------------insert the code
if (timer < -4) {
background(255, 255, 255);
// text('eg, canvas, graffiti, hand drawn, digital, etc', margin, margin + 70);
//---------------------------------to have the button and input not repeating
if (on == 0) {
on = 1;
button = createButton('next image');
button.position(margin, 500);
button.mousePressed(buttonPressed);
}
}
}
//-----------------------------------------------BUTTONPRESSED
function buttonPressed() {
timer = 5;
imagecounter++
}
//-----------------------------------------------PRINT INPUT
function myInputEvent() {
console.log('you are typing: ', this.value());
word = this.value();
}
//-----------------------------------------------EXPORT
function export_data() {
saveTable(data, '1.2_YourName_VCDAssignment2.csv');
}