Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Using slider to change randomSeed

$
0
0

Hi all, i'm trying to control a randomSeed() parameter with a slider to create a random number that i can use again in a running sketch, i'm having problems to change the randomSeed, it always get stucked, if i comment the line 31( "sliderValue= int(random(10));") it runs ok, but of course i don't have the random, here's the sketch:

import controlP5.*;

ControlP5 cp5;

//int sliderValue;
int caos, sliderValue;
color myColor;

void setup() {
  size(700, 400);
  noStroke();
  cp5 = new ControlP5(this);

  cp5.addSlider("sliderValue")
    .setPosition(100, 50)
      .setRange(0, 10)
        .setNumberOfTickMarks(10)
          ;

  cp5.addSlider("caos")
    .setPosition(100, 100)
      .setRange(0, 10)
        .setNumberOfTickMarks(10)
          ;
}

void draw() {
  background(0);

  randomSeed(caos);
  sliderValue= int(random(10));

  fill(map(sliderValue, 0, 10, 0, 255));
  rect(0, 0, width, 100);

  println("SLIDER VALUE", sliderValue);
  println("CAOS", caos);
}

void slider(float theColor) {
  myColor = color(theColor);
  println("a slider event. setting background to "+theColor);
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles