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.
IndexProgramming Questions & HelpSyntax Questions › random word change in ellipse
Page Index Toggle Pages: 1
random word change in ellipse (Read 580 times)
random word change in ellipse
Mar 29th, 2009, 1:37pm
 
Hello I have a ellipse where words on moving. The words are from a XML file. When a word is at some x and some y coordinate I want that the word changes to an athor randomly.
Can someone help me with that.
I Only get that the words are changeing random continiously Sad

Sorry for my bad english
Re: random word change in ellipse
Reply #1 - Mar 29th, 2009, 1:52pm
 
Perhaps you could post some example code.  I'm not sure I understand enough to help.
Re: random word change in ellipse
Reply #2 - Mar 29th, 2009, 10:29pm
 
Code:
PFont Grieks;
PImage imageA;
float a = 180;
XMLElement xml;
int q;

float fontSize = 15; // Size of the text
float fontMax = 55; // Maximum size of the font
float fontMin = 15; // Minimum size of the font
float fontInc = 0.3; // Increasment and decreasment of the font

float fontColor = 255; // Color of the text

void setup() {
size(1024, 600, P3D);
background(25, 25, 112);
frameRate(25);
smooth();

xml = new XMLElement(this, "teksten.xml");
int q = xml.getChildCount();

// Load the font. Fonts must be placed within the data
// directory of your sketch. Use Tools > Create Font
// to create a distributable bitmap font.
// For vector fonts, use the createFont() function.
Grieks = loadFont("Grieks.vlw");
imageA = loadImage("plato en ari klein.gif");

}



void draw() {

background(25, 25, 112);
a = a + 0.02;
if (a > 360) {
a = 0;
}

// Translate the origin point to the center of the screen
translate(width/2,height/2);

// Coordinates ellips
float x = 310 * cos(a);
float y = 80 * sin(a);

// Text smaller and color darker
if(x < 0 && y < 80){
fontSize = fontSize - fontInc;
fontColor = fontColor - 1;
if(fontSize < fontMin){
fontSize = fontMin;
}
if(fontColor < 0){
fontColor = 0;
}
}

// Text bigger and color whiter
if(x > 0 && y > -80){
fontSize = fontSize + fontInc;
fontColor = fontColor + 1.5;
if(fontSize > fontMax){
fontSize = fontMax;
}
if(fontColor > 255){
fontColor = 255;
}
}

// Set Text size
textFont(Grieks, fontSize);

// Draw the ellipse at the cartesian coordinate
ellipseMode(CENTER);
fill(fontColor);
textAlign(CENTER);

int w = int(random(3));
XMLElement kid = xml.getChild(w);
String tekst = kid.getContent();

text(tekst, x, y);

imageMode(CENTER);
if(y < 0){
translate(-5, -20, 1);
}
if( y > 0){
translate(

This is the code. I know it's a bit mesy..
Re: random word change in ellipse
Reply #3 - Mar 30th, 2009, 9:30am
 
okay i solved the problem. But now i have the problem that the moving image is not moving nicely. When I set smooth() off it is not going 3d anymore Huh does some one know the problem
Page Index Toggle Pages: 1