We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
random() (Read 622 times)
random()
Sep 9th, 2007, 2:34pm
 
hi im trying to get this bit of code to randomise between selecting variables a,b,c,d or e foreach fill, stroke, textpos. as you can see i have only got up to assigning the variables, not randomising them so on each run there is a different result. any ideas?

also, is there a more high-res mode more suitable for printing of content?


kind regards
mike

the code::

void setup() {

 size(255, 255);

 float a = (255/1.6);
 float b = (128/1.6);
 float c = (255/2);
 float d = (255);
   float e = (0);
  size(400, 400);
 background(d, d, b);
}

void draw() {

 PFont font;
// The font must be located in the sketch's
// "data" directory to load successfully
font = loadFont("FranklinGothic-Medium-24.vlw");
float a = (255/1.6);
 float b = (128/1.6);
 float c = (255/2);
 float d = (255);
 float e = (0);
textFont(font, 32);
text("Modulor", a, d);
fill(a, b, c);
textFont(font, 20);
text("LeCorbusier", b, a);
fill(b, c, a);  
stroke(a, b, c);
line (0,b,d,e);
line (0,1,a,101);
line (e,b,100,102);
line (0,3,a,a);
line (100,e,b,200);
line (c,d,a,e);
line (100,102,d,a);
line (a,103,250,400);
}
Re: random()
Reply #1 - Sep 10th, 2007, 8:53pm
 
You should put your variables in an array,
and then randomly select an INDEX into the array.

// first, put variables into array called "value"

// select one of the N variables

i = floor(random(0,N));
fill(value[i]);

-- djones
Re: random()
Reply #2 - Sep 10th, 2007, 9:22pm
 
thanks for the help. thats exactly what i had in mind- any ideas about making it more highres as im looking to print the results of my experiments

regards
mike
Re: random()
Reply #3 - Sep 10th, 2007, 9:37pm
 
my specific concern is with the text, which is very pixelated at both small and large point sizes. looks a bit like i did it im mspaint lol.

ive tried smooth() which seems to only make the pixels larger, not anti-aliased


m
Page Index Toggle Pages: 1