// the error range for the tangent position and angle
float ANGLEERROR = 0.3;
float POINTERROR = 0;
float LENGTHTANGENT = 20;
// the initial text
String msg = "RShape";
String FONT = "lucon.ttf";
//the alpha value of the lines
int ALPHAVALUE = 10;
//the velocity of the calligraphy
int VELOCITY =10;
int MARGIN = 50;
Hi there,
I tried to create some unique shape with alphabets with the following codes. But i have to keep change the string variable manually. Is there a way to change the string input after i run the code? Means after i run the code, it will output the default unique shape, but when i key in any letter or symbol, it will over-write the previous string and display the new unique shape with the new string input. I tried to name the string and using keypress function, but it does not allow me to do so. Please advise me. Thanks.The following is the code:
HELP!!! ENCOUNTER ERROR WHEN TRYING THE FOLLOWING CODE:
import geomerative.*;
RFont f;
RGroup grp;
RShape s;
float len;
float angle;
float pos;
//---------------------Runtime properties--------------
// save each frame
boolean SAVEVIDEO =false;
boolean SAVEFRAME = false;
boolean APPLICATION =false;
String DEFAULTAPPLETRENDERER = JAVA2D;
int DEFAULTAPPLETWIDTH = 600;
int DEFAULTAPPLETHEIGHT = 600;
String DEFAULTAPPLICRENDERER = OPENGL;
int DEFAULTAPPLICWIDTH = 600;
int DEFAULTAPPLICHEIGHT = 600;
// the error range for the tangent position and angle
float ANGLEERROR = 0.3;
float POINTERROR = 0;
// the length variation of the tangent
//-> 500: sketchy, blueprint
// -> 150: light blueprint
// -> 2000: mystic
float LENGTHTANGENT = 130;
// the initial text
String STRNG = "S";
String FONT = "arial.ttf";
//the alpha value of the lines
int ALPHAVALUE = 2;
//the velocity of the calligraphy
int VELOCITY =10;
int MARGIN = 50;
String newString ="";
void setup (){
int w = DEFAULTAPPLICWIDTH, h = DEFAULTAPPLICHEIGHT;
String r = DEFAULTAPPLICRENDERER;
if(!APPLICATION){
//specify the width and height at runtime
w =int(param("width"));
h =int(param("height"));
r =(String)param("renderer");
//string will return null if param("renderer") doesn't exist
if(r !=OPENGL && r != P3D && r != JAVA2D && r != P2D) {
r = DEFAULTAPPLETRENDERER;
}
//int() will return 0 if param("width") doesnt exist
if (w <= 0) {
w = DEFAULTAPPLETWIDTH;
}
//int() will return 0 if param("height") doesnt exist
if (h <= 0) {
h = DEFAULTAPPLETHEIGHT;
}
}
size(w,h,r);
background(255);
frameRate(25);
LENGTHTANGENT = LENGTHTANGENT * width/800F;
try{
smooth();
}catch(Exception e){}
noFill();
stroke(0,0,0,50);
f = new RFont(this,FONT,372,RFont.CENTER);
initialize();
}
void draw(){
pushMatrix();
translate(width/2,height/2);
//Draw very low alpha and long tangents on random points of each letters
for (int i =0; i<grp.countElements(); i++){
s = (RShape)(grp.elements[i]);
for (int j=0; j<s.countSubshapes();j++){
for(int k=0;k<VELOCITY; k++){
pos = random(0,1);
RPoint tg = s.subshapes[j].getCurveTangent(pos);
RPoint p = s.subshapes[j].getCurvePoint(pos);
p.x = p.x +random(-POINTERROR,POINTERROR);
p.y = p.y +random(-POINTERROR,POINTERROR);
len = random(-LENGTHTANGENT, LENGTHTANGENT);
angle = atan2(tg.y,tg.x) + random(-ANGLEERROR,ANGLEERROR);
bezier(p.x,p.y,10,10,90,90,15,80);
}
}
}
popMatrix();
}
void initialize(){
grp = f.toGroup(STRNG);
grp.centerIn(g,MARGIN,1,1);
background(255);
}
Hi there,
I would like to create a font that will change it's shape when i move the mouse. Anyone has any idea how to create it?? I've been trying this for weeks but still can't find any solution.
The following is a tutorial code i found on the site, i want to create something similar. Instead of turning 360degree by itself, i want to control it by the mouse movement, and the font will only change it's shape when i move the mouse.