View Single Post
Old 12-22-2018, 08:28 AM   #3
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,167
Default

Holy sh.... I'm really a hacker!

Change it to this and you will have the perfect text box which moves with the text:


Code:
gfx_fillrect(project_w*xpos, yt, txtw, txth*(1+border*2));

Nope this does not work! Though it moves the box it does 
it not the same way as the Text.
No, forget it. It was just luck that the textbox fitted the text perfectly. But I'm sure this txtw it the right variable as this obviously is the text width. Ah, i guess the problem is that x-position has to be added or subtracted. xpos and txtw!

edit: Problem is: If xpos is 0, everything is right. If xpos is 0.5, the text centers but the box starts in the middle. If xpos is 1 the box is outside the screen. So we need something to center the box the same way as the text. I short before the brake thru!

edit again: Yeah!!! Got it. Found is in the other code.

Code:
gfx_fillrect(xpos*(project_w-txtw), yt, txtw, txth*(1+border*2));
Edit again, again: If you want left and right spacing insert a pixel count as shown.
Code:
gfx_fillrect(xpos*(project_w-txtw)-10, yt, txtw+20, txth*(1+border*2));

Whohoooo!

Last edited by Eliseat; 12-22-2018 at 09:03 AM.
Eliseat is offline   Reply With Quote