random color letter with mgraphics

Oct 25, 2012 at 1:15pm

random color letter with mgraphics

Hello

I’m trying to write a string with random color for each letter
is anyone know how to do this with jsui?

here’s my code first test,the problem is that between each letter the “pencil” go to up/left corner… i could write “move_to(x,y)” but i don’t know the width of the precedent letter…

*************************************************************
mgraphics.init();
mgraphics.relative_coords = 1;
//mgraphics.autofill = 0;

var stringA = new Array();
var strCl = new String (“boby”);
mgraphics.redraw();

function bang(){
mgraphics.redraw();
}

function paint(){
mgraphics.move_to(-0.8, 0.5);
mgraphics.set_font_size(60);

for (e = 0; e < strCl.length; e++) {
with(mgraphics){
set_source_rgb(Math.random(),Math.random(),Math.random());
text_path(strCl.charAt(e));
fill();
}
}

}

thanks

#64920
Oct 26, 2012 at 8:26am

up :)

please…

#234065
Oct 26, 2012 at 10:13am

If you look in here:

http://cycling74.com/forums/topic.php?id=36044

You will find all of the mgraphics Patch-a-day stuff. On November 30th, I did a routine that did text justification, and I used the “text_measure” routine to determine where things were at. That patch/javascript combo will probably give you enough information to do what you want.

#234066
Oct 26, 2012 at 3:21pm

thanks a lot Darwin, I haven’t noticed ” text_measure”… that is what i need
your patch a day serie was great!!

PB

#234067

You must be logged in to reply to this topic.