Update:
I found the command textAlign, but it doesn’t do what I need
I want to create a loop that runs for example 50 times,
And each time it write word in the center of the screen, in smaller font,
Here is my code:
{
int x1, y1;
x1=width/2;
y1=height/2;
for (int j=100; j>0;j-=2)
{
int c = int(random(255));
fill(c,c,c);
textAlign(CENTER, CENTER);
textSize(j);
text("TODAY", x1, y1);
}
But the alignment to the horizontal center is not really refers to the center of the screen,
because the result is this:
The question is - how do I calculate how much should I move the text?
glv
October 17, 2021, 3:07pm
2
Hello,
See the related items :
https://processing.org/reference/text_.html
Also this and the related items:
https://processing.org/reference/width.html
Lots of resources here:
:)
jafal
October 17, 2021, 3:27pm
3
Hi
I think this is useful
https://processing.org/tutorials/data
And this is how text array …could guide from an idea
hi all
how to text array elements i have try but i could not do it looks random and wrong code
any help
thanks in advance
void setup () {
size ( 800 , 800 );
}
void draw () {
fill(0);
int[] x = {
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
6…
glv
October 17, 2021, 3:54pm
4
@yalaniv ,
Take a look at this topic:
I am developing a sketch to graphically display GPS data coming from an Arduino. The sketch paints the background and “gauge” bezel and then calls various functions to fill in the face with appropriate data,
.
The compass function paint dots for 5 degree gradations in a circle inside the bezel. Following the dots the directional characters are displayed in a circle around the dots. Finally a pointer is painted.
The first time through the function, all is well. The second time through the fun…
It will help you get to this:
:)
if i understand correctly i think what you need to do is draw the letters individually. you can see an example of what i mean below
and here’s the code i used (note this is really rough and i didn’t bother too much so no doubt it can be improved and you will need to mess with the inner character scaling)
String letters;
float defaultWidth, spread;
int layers, fontSize, scaleFactor;
int[] shadePalette;
void setup() {
size(800, 600, P2D);
fontSize = 100;
scaleFactor = 10;
textSize(fontSize);
textAlign(CENTER, CENTER);
letters = "TODAY";
defaultWidth = textWidth(letters);
spread = defaultWidth / letters.length();
layers = 10;
shadePalette = new int[layers];
for(int i = 0; i < layers; i++) {
//shadePalette[i] = 255 - (255 / (i + 1));
shadePalette[i] = int(random(255));
}
}
void draw() {
background(0);
int i, j;
for(i = 0; i < layers; i++) {
fill(shadePalette[i]);
textSize(fontSize - i * 4);
for(j = 0; j < letters.length(); j++) {
char c = letters.charAt(j);
text(c, (width / 2 - defaultWidth / 2) + (j * (fontSize - j * 4)), height / 2 + i);
}
}
}
1 Like
glv
October 18, 2021, 10:28am
6
@yalaniv ,
Tutorials related to text:
References:
:)
I tried to copy all this code and run it, and got an error:
gluegen-rt.dll: Can’t find dependent libraries
A library relies on native code that’s not available.
Or only works properly when the sketch is run as a 32-bit application.
I usually work with the 64-bit app
this is raw processing 4 code. that error is unrelated to the code i posted.
1 Like
I just copy it and paste…
What can be the error?