Tabnine Logo
PApplet.random
Code IndexAdd Tabnine to your IDE (free)

How to use
random
method
in
processing.core.PApplet

Best Java code snippets using processing.core.PApplet.random (Showing top 17 results out of 315)

origin: stackoverflow.com

 void setup(){
  Tree tree = new Tree(this);
}

class Tree{

  public Tree(PApplet sketch){
   float x = sketch.random(100);
  }
}
origin: org.processing/core

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  float temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: ajavamind/Processing-Cardboard

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  int temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: ajavamind/Processing-Cardboard

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  float temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: org.processing/core

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  int temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: ajavamind/Processing-Cardboard

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  String temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: org.processing/core

/**
 * Randomize the list order using the random() function from the specified
 * sketch, allowing shuffle() to use its current randomSeed() setting.
 */
public void shuffle(PApplet sketch) {
 int num = count;
 while (num > 1) {
  int value = (int) sketch.random(num);
  num--;
  String temp = data[num];
  data[num] = data[value];
  data[value] = temp;
 }
}
origin: ajavamind/Processing-Cardboard

/**
 * Return a random number in the range [howsmall, howbig).
 * <p/>
 * The number returned will range from 'howsmall' up to
 * (but not including 'howbig'.
 * <p/>
 * If howsmall is >= howbig, howsmall will be returned,
 * meaning that random(5, 5) will return 5 (useful)
 * and random(7, 4) will return 7 (not useful.. better idea?)
 */
public final float random(float howsmall, float howbig) {
  if (howsmall >= howbig) return howsmall;
  float diff = howbig - howsmall;
  return random(diff) + howsmall;
}
origin: poqudrof/PapARt

private PVector createRandomPoint() {
  return new PVector(
      parent.random(deadZone, pw - deadZone),
      parent.random(deadZone, ph - deadZone),
      parent.random(HALF_PI));
}
origin: stackoverflow.com

 import processing.core.*;

public class Site {
  public static final int COUNT       = 8;
  public static final int MAX_VEL     = 2;
  public static final int MARKER_SIZE = 6;

  PApplet parent;

  float x, y;
  PVector vel;

  int c;

  Site(PApplet p) {
    parent = p;
    vel = new PVector(
      parent.random(-MAX_VEL, MAX_VEL),
      parent.random(-MAX_VEL, MAX_VEL)
    );     
  }   
}
origin: org.processing/core

 value = random(diff) + low;
} while (value == high);
return value;
origin: ajavamind/Processing-Cardboard

/**
 * Make a new 3D unit vector with a random direction
 * @return the random PVector
 */
static public PVector random3D(PVector target, PApplet parent) {
 float angle;
 float vz;
 if (parent == null) {
  angle = (float) (Math.random()*Math.PI*2);
  vz    = (float) (Math.random()*2-1);
 } else {
  angle = parent.random(PConstants.TWO_PI);
  vz    = parent.random(-1,1);
 }
 float vx = (float) (Math.sqrt(1-vz*vz)*Math.cos(angle));
 float vy = (float) (Math.sqrt(1-vz*vz)*Math.sin(angle));
 if (target == null) {
  target = new PVector(vx, vy, vz);
  //target.normalize(); // Should be unnecessary
 } else {
  target.set(vx,vy,vz);
 }
 return target;
}
origin: ajavamind/Processing-Cardboard

/**
 * Make a new 2D unit vector with a random direction
 * @return the random PVector
 */
static public PVector random2D(PVector target, PApplet parent) {
 if (parent == null) return fromAngle((float)(Math.random()*Math.PI*2),target);
 else                return fromAngle(parent.random(PConstants.TWO_PI),target);
}
origin: poqudrof/PapARt

void initScreenPoints() {
  screenPoints = new PVector[nbScreenPoints];
  pw = this.getDisplay().getWidth();
  ph = this.getDisplay().getHeight();
  // 1 in each quadrant. 
  // 2 random
  screenPoints[0] = new PVector(pw / 2, ph / 2, 0);
  screenPoints[1] = new PVector(
      parent.random(deadZone, pw / 2 - deadZone),
      parent.random(deadZone, ph / 2 - deadZone),
      parent.random(HALF_PI));
  screenPoints[2] = new PVector(
      parent.random(pw / 2 + deadZone, pw - deadZone),
      parent.random(deadZone, ph / 2 - deadZone),
      parent.random(HALF_PI));
  screenPoints[3] = new PVector(
      parent.random(deadZone, pw / 2 - deadZone),
      parent.random(ph / 2 + deadZone, ph - deadZone),
      parent.random(HALF_PI));
  screenPoints[4] = new PVector(
      parent.random(pw / 2 + deadZone, pw - deadZone),
      parent.random(ph / 2 + deadZone, ph - deadZone),
      parent.random(HALF_PI));
  for (int i = 5; i < nbScreenPoints; i++) {
    screenPoints[i] = createRandomPoint();
  }
}
origin: org.processing/core

/**
 * Make a new 2D unit vector with a random direction. Pass in the parent
 * PApplet if you want randomSeed() to work (and be predictable). Or leave
 * it null and be... random.
 * @return the random PVector
 */
static public PVector random2D(PVector target, PApplet parent) {
 return (parent == null) ?
  fromAngle((float) (Math.random() * Math.PI*2), target) :
  fromAngle(parent.random(PConstants.TAU), target);
}
origin: org.processing/core

/**
 * Make a new 3D unit vector with a random direction
 * @return the random PVector
 */
static public PVector random3D(PVector target, PApplet parent) {
 float angle;
 float vz;
 if (parent == null) {
  angle = (float) (Math.random()*Math.PI*2);
  vz    = (float) (Math.random()*2-1);
 } else {
  angle = parent.random(PConstants.TWO_PI);
  vz    = parent.random(-1,1);
 }
 float vx = (float) (Math.sqrt(1-vz*vz)*Math.cos(angle));
 float vy = (float) (Math.sqrt(1-vz*vz)*Math.sin(angle));
 if (target == null) {
  target = new PVector(vx, vy, vz);
  //target.normalize(); // Should be unnecessary
 } else {
  target.set(vx,vy,vz);
 }
 return target;
}
origin: poqudrof/PapARt

float g = ((float) out[1] - y) / mag + 0.5f;// / frameHeight; 
mapImg.pixels[k++] = parent.color(r, g, parent.random(1f));
processing.corePAppletrandom

Javadoc

Return a random number in the range [0, howbig).

The number returned will range from zero up to (but not including) 'howbig'.

Popular methods of PApplet

  • constrain
  • createGraphics
    Create an offscreen graphics surface for drawing, in this case for a renderer that writes to a file
  • loadStrings
    ( begin auto-generated from loadStrings.xml ) Reads the contents of a file or url and creates a Stri
  • saveStrings
    ( begin auto-generated from saveStrings.xml ) Writes an array of strings to a file, one line per str
  • abs
  • createImage
    ( begin auto-generated from createImage.xml ) Creates a new PImage (the datatype for storing images)
  • createShape
  • createWriter
    ( begin auto-generated from createWriter.xml ) Creates a new file in the sketch folder, and a PrintW
  • loadImage
  • main
    main() method for running this class from the command line. Usage: PApplet [options] [s
  • max
  • parseInt
  • max,
  • parseInt,
  • round,
  • split,
  • sqrt,
  • unhex,
  • arrayCopy,
  • ceil,
  • checkExtension

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • putExtra (Intent)
  • setScale (BigDecimal)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Notification (javax.management)
  • Runner (org.openjdk.jmh.runner)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now