How do I call fill() in a function?

So I have a function tied to rendering and I used fill in it like this:

public static int rd(int k){
  return k;

It said something along the lines of you can’t call fill() in a static context. I tried removing the static keyword and I didn’t get an error but
fill() didn’t work, it just kept the old color. Can I fix this?

You can request the sketch’s PApplet object:

static public void rd(final PApplet p, final int k) {
  p.line(0, 0, 0, k);

Or its PGraphics canvas object:

static public void rd(final PGraphics pg, final int k) {
  pg.line(0, 0, 0, k);

Yes, but when I call the function I need to provide a PApplet in the parameters.

static methods don’t have access to keyword this and therefore can only deal w/ arguments which are passed to it: :face_with_monocle:

Yeah but I made my function non static