TUTORIAL

Random()

	
	random()
	Generates random numbers. Each time the random() function is called, it returns an unexpected value within the specified range.
	Reference:http://www.processing.org/reference/random_.html
	Syntax 	random(value1);
	random(value1, value2);

	Let's start!

	//Programed by Yeohyun Ahn

	size(250,250);

	PFont font;
	font = loadFont("Univers-Condensed-48.vlw");
	background(255);

	for(int i=0;i<250;i=i+20){

	textFont(font, 22);

	fill(0,0,0);
	text("A", random(i), 100);

	}


	Output:
	       

	Without random()                 With random()







	//Programed by Yeohyun Ahn

	size(250,250);

	PFont font;
	font = loadFont("Univers-Condensed-48.vlw");
	background(255);

	for(int i=0;i<250;i=i+20){

	textFont(font, 22);
	fill(0,0,0);
	text("B", random(i), 100);

	if(i==0 || i== 40 || i==80 || i==120 || i==160 || i==200 || i==240 )

	{

	textFont(font, 42);
	fill(0,0,0,150);
	text("C", random(i), 120);

	}
	}


	Output:

	    

	Without random()               With random()




	//Programed by Yeohyun Ahn
	size(400,400);
	PFont font;
	font = loadFont("Univers-Condensed-48.vlw");
	background(255);

	for(int i=0;i<400;i=i+20){
	for(int j=0;j<400;j=j+20){

	fill(0,0,0);
	textFont(font, 22);
	text("T", i, j);
	}
	}
	Output:

	
	
	

	text("T", i, j); 	text("T", random(i), j);
	text("T", i, random(j)); 	text("T", random(i), random(j));
	textFont(font, random(abs(i-330)));
	text("T",i, random(j)); 	fill(0,0,0,random(abs(i-150)));
	textFont(font, random(abs(i-330)));
	text("T",i, random(j));




	Exercise1) Change the value of 'i,' and 'j' as well as change your font size, styles, and color.

	//Programed by Yeohyun Ahn

	int count=0;

	void setup(){
	size(500,500);

	PFont font;
	font = loadFont("Bodoni-48.vlw");
	background(255);
	textFont(font, 142);
	}

	void draw(){


	if(mousePressed)
	{

	for(int i=300;i<800;i=i+1)
	{

	if(count%2==0)
	{
	text("A", random(abs(i-250)+i), random(abs(i-250)+i));
	fill(0, 0, 0,255);
	rotate((PI/3.0)+i);
	}else
	{
	text("A", random(abs(i-250)+i), random(abs(i-250)+i));
	fill(255, 255, 255,255);
	rotate((PI/3.0)+i);
	}

	}

	count++;

	}

	}



	Output:
	
	
			

	Exercise2) Change the value of 'i,' and 'j' as well as change your font size, style, and color.



	Extra Tips:

	abs()
	Calculates the absolute value (magnitude) of a number.
	Reference:http://www.processing.org/reference/abs_.html