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

**URL:** https://discourse.processing.org/t/help-me-it-is-about-making-random-color-in-toxiclibs-library/20541
**Category:** Libraries
**Tags:** homework
**Created:** [May 6, 2020, 2:57pm UTC](https://discourse.processing.org/t/help-me-it-is-about-making-random-color-in-toxiclibs-library/20541 "2020-05-06T14:57:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![narabagus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/narabagus/32/9091_2.png) [@narabagus](https://discourse.processing.org/u/narabagus)
#### Post date: [May 6, 2020, 2:57pm UTC](https://discourse.processing.org/t/help-me-it-is-about-making-random-color-in-toxiclibs-library/20541/1 "2020-05-06T14:57:39Z")

</div>

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

```auto
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

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [May 6, 2020, 3:30pm UTC](https://discourse.processing.org/t/help-me-it-is-about-making-random-color-in-toxiclibs-library/20541/2 "2020-05-06T15:30:37Z")

</div>

Would `TColor.newRandom()` work for you?

> <https://github.com/postspectacular/toxiclibs/blob/master/src.color/toxi/color/TColor.java#L366>

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [May 6, 2020, 3:33pm UTC](https://discourse.processing.org/t/help-me-it-is-about-making-random-color-in-toxiclibs-library/20541/3 "2020-05-06T15:33:36Z")

</div>

And welcome to the forum! 🙂
