We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone,
I'm just wondering how do you successfully and smoothly increase/decrease the scale of text/type by the positioning of mouse Y?
Basically, when the mouse is at the top of the window I want the text to be small, and when it's at the bottom I want it to be big, and while transitioning from big to small, it is smooth as if it is growing. I hope this makes sense.
At the moment the text jumps from small to big instantly.
As you can tell I'm a beginner, and this may be a very simple command, but regards to coding so far I have:
void setup() { size(1000, 1000);
}
void draw() {
float x = mouseX;
float y = mouseY;
background(0);
if(mouseY>500)
textSize(100);
if(mouseY<500)
textSize (20);
text("john", x, height/2, y, height/2);
}
Thanks in advance!
Answers
This will give you smooth text scaling between sizes 10 and 410
Ah thank you so much!
@TypeCoding -- if you want to add a time lag or slow growth rate to quark's demo sketch, save the previous size t the end of each
draw()
and uselerp()
at the beginning of each draw to calculate the new size from the previous. The amount (amt) from 0-1 that you set in lerp will be how smoothly or sharply your value changes.https://processing.org/reference/lerp_.html