Help me! It is about making random color in ToxicLibs library

Hi! I’m currently making an abstract pattern project using a ToxicLibs. Below is the coding :slight_smile:

import toxi.sim.grayscott.*;
import toxi.color.*;

int NUM_ITERATIONS = 5;

GrayScott gs;
ToneMap toneMap;

void setup() {
  size(480,480);
  gs=new GrayScott(width,height,false);
  gs.setCoefficients(0.011,0.05,0.12,0.04);
  
  ColorGradient grad=new ColorGradient();

  grad.addColorAt(0,NamedColor.BLACK);
  grad.addColorAt(200, NamedColor.BLUE);
  grad.addColorAt(100,NamedColor.RED);

  toneMap=new ToneMap(0.3,0.5,grad);
}

void draw() {
  if (mousePressed) {
    gs.setRect(mouseX, mouseY,30,30);
  }
  loadPixels();
  for(int i=0; i<NUM_ITERATIONS; i++) {
    gs.update(5);
  }
  toneMap.getToneMappedArray(gs.v,pixels);
  updatePixels();
}

void keyPressed() {
  gs.reset();
}

I use ColorGradient to add color. That’s very nice. I can combine two different color gradient and it looks beautiful. However, I want more than that, I want to make a random color whenever i click the mouse. So, do you have any suggestion what is the best code to get a random color with ToxicLibs? Thank you for your help

1 Like

Would TColor.newRandom() work for you?

1 Like

And welcome to the forum! :slight_smile: