Changes

Jump to: navigation, search

FSOSS 2010/processing.js/randomText

747 bytes added, 20:34, 27 October 2010
Created page with '<source lang="JavaScript"> FSOSS 2010 Andor Salga Example of random and text: PFont font; float textY, textX; String textString = new String(); // color does not use …'
<source lang="JavaScript">
/*
FSOSS 2010
Andor Salga
Example of random and text
*/
PFont font;
float textY, textX;
String textString = new String();

// color does not use 'new'
color col = color(80, 90, 100);

void setup(){
size(250, 250);
font = createFont("verdana", 30);
textFont(font);
}

void draw(){
background(0);

// move text up
textY -= 0.5;

// text uses fill, not stroke colors
fill(col);
text(textString, textX, textY);
}


void mousePressed(){
textX = mouseX;
textY = mouseY;

// Create a random number from 0 to 10
// not including 10
float rand = random(0, 10);

// Convert the float to a String
textString = new String("" + rand);
}
</source>
[http://studio.sketchpad.cc/PdhuUmFdrz Run me]
1
edit

Navigation menu