Processing 3 Object Class not Being Displayed

Hi. I am a total noob to object classes. I do not know what I am doing wrong. Here’s an image of the prototype:


I am trying to create an object class for the encircled cards.
I have saved the class on a separate page.
I don’t know which piece of code is causing the problem in this case. The main page or the class page.
Here’s the main code where I call the function:

void setup() { 
  size(1200, 750); 
  background(bg);
  montserratExtraBold = createFont("montserratExtraBold.ttf", headingSize);
  montserratRegular = createFont("montserratRegular.ttf", callToActionSize);
  
  y1 = new Timeline_Years();
  y1.display();
}

Here’s the code for the class

 //constructor
  Timeline_Years(){
    //text
    yearOriginX = 132;
    yearOriginY = 171;    
    year = "1900";
    yearColor = #FEFEFE;
    //background   
    boxOriginX = 163;
    boxOriginY = 124;
    boxColor = #ffffff;
    boxWidth = 74;
    boxHeight = 45;
  }
  
  //functions
  void display(){
    //bg
    fill(boxColor);
    rect(boxOriginX, boxOriginY, boxWidth, boxHeight);
    
    //text
    int yearSize;
    yearSize = 20;
    PFont montserratBold;
    montserratBold = createFont("montserratBold.ttf", yearSize);
    fill(yearColor);
    textFont(montserratBold);
    text(year, yearOriginX, yearOriginY);    
  }
}

Here’s a link to the zipped version of the file in case that helps:

Thanks in advance.

You don’t describe what you see (falsely) and what you want to see happening instead

Your screen shot is good but does it show your current false version or what you want to see instead?

When your class represents ONE time card you should define in setup () an Array of that class

And year should be different for each object in the Array

1 Like

This should be in draw()

Doesn’t the rectangle appear or the text in it or both??

Don’t repeat the textfont stuff in display() you defined in setup globally, so don’t repeat this variable in the class

1 Like