Old 12-22-2018, 06:20 AM   #1
Winfield
Human being with feelings
 
Winfield's Avatar
 
Join Date: Jan 2007
Location: The Underground Bunker
Posts: 705
Default 'Text box' in videoprocessor - possible?

Hi, I need a 'floating text box' - is it possible?

The video preset 'Title text overlay' and Jons (Reaper blog) 'JT: Essential Text Overlay' both have backgrounds filling the entire screen from left to right.

The use case examples would be for that 'censured' black box over the eyes or for making a green box for 'chroma keying'.

Ideally it should be free size and free placement and of any color.

Any help appreciated

Thanks
-W
__________________
"if DAWs are religions, REAPER is atheism" - The big J
__________________
Windows 10x64 | Asus Z170-a i7, 32GB ram | RME-Digiface USB
Winfield is offline   Reply With Quote
Old 12-22-2018, 08:24 AM   #2
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Let me - a really cool Video processor hacker - tell you something.

I found out that you could manually change the box's start and end by changing the following values. (default Text overlay from dev Reaper)
PHP Code:
gfx_fillrect(0ytproject_wtxth*(1+border*2)); 
to
PHP Code:
gfx_fillrect(100yt100txth*(1+border*2)); 
0 -> 100
project_w -> 100

I changed it to one hundred. And as I understand it right the first value describes the horizontal start of the box and the second value the width from that start point. So in this case the box would be drawn at 100 px until 200 px. It feels like it would be pretty easy to insert just a variable and change it with parameter knobs. But I'm in a hurry right now.

Greetings
ELi
Eliseat is offline   Reply With Quote
Old 12-22-2018, 08:28 AM   #3
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
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
Old 12-22-2018, 09:12 AM   #4
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Whohooo! My first working code change! (The kids are hungry and I had to make some shopping. But hey, this was more important )

Code:
// Text overlay
#text="What is going on? Is there something wrong?"; // set to string to override
font="Arial";

//@param1:size 'text height' 0.05 0.01 0.2 0.1 0.01
//@param2:ypos 'y position' 0.95 0 1 0.5 0.01
//@param3:xpos 'x position' 0 0 1 0.5 0.01
//@param4:border 'border' 0 0 1 0.5 0.01
//@param5:fgc 'text bright' 1.0 0 1 0.5 0.01
//@param6:fga 'text alpha' 1.0 0 1 0.5 0.01
//@param7:bgc 'bg bright' 0.75 0 1 0.5 0.01
//@param8:bga 'bg alpha' 0.5 0 1 0.5 0.01
//@param9:lrs 'l/r spacing' 0 0 100 0.5 1

input = 0;
project_wh_valid===0 ? input_info(input,project_w,project_h);
gfx_blit(input,1);
gfx_setfont(size*project_h,font);
strcmp(#text,"")==0 ? input_get_name(-1,#text);
gfx_str_measure(#text,txtw,txth);
yt = (project_h- txth*(1+border*2))*ypos;
gfx_set(bgc,bgc,bgc,bga);
gfx_fillrect(xpos*(project_w-txtw)-lrs, yt, txtw+lrs*2, txth*(1+border*2));
gfx_set(fgc,fgc,fgc,fga);
gfx_str_draw(#text,xpos * (project_w-txtw),yt+txth*border);
The last parameter changes the spacing of the box. I hope it works as expected. I'm pretty happy right now.

And it was kind of fun.

But now I have to go!
Eliseat is offline   Reply With Quote
Old 12-22-2018, 09:26 AM   #5
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 7,568
Default

My take on it
Code:
// JT: Essential filled rectangle
// makes a rectangle of any color

//@param1:wet 'opacity' 1.0 0 1 0.5 0.01 
//@param2:R 'Red' 0.5 0 1 0.5 0.01
//@param3:G 'Green' 0.5 0 1 0.5 0.01
//@param4:B 'Blue' 0.5 0 1 0.5 0.01

//@param6:w1 'Width' 50 2 1920 50 2
//@param7:h1 'Height' 50 2 1080 50 2

//@param9:P1 'X position' 50 0 100 50 1
//@param10:P2 'Y position2' 50 0 100 50 1
src=0;
PW=Project_w/100;
PH=Project_h/100;

gfx_blit(0);
gfx_mode=1;
gfx_set(R,G,B,wet);

//line
gfx_gradrect((PW*P1-(w1/2)),(PH*P2-(h1/2)),w1,h1,R,G,B,wet);
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog

Last edited by EpicSounds; 12-22-2018 at 09:37 AM. Reason: better center aligned preset
EpicSounds is offline   Reply With Quote
Old 12-22-2018, 11:45 AM   #6
Sumalc
Human being with feelings
 
Join Date: Oct 2009
Location: France
Posts: 743
Default

Thank you very much to you, both presets go well together.
Sumalc is offline   Reply With Quote
Old 12-22-2018, 03:14 PM   #7
Winfield
Human being with feelings
 
Winfield's Avatar
 
Join Date: Jan 2007
Location: The Underground Bunker
Posts: 705
Default

Thanks Eli and Jon - great stuff, thanks a lot!

Quote:
Originally Posted by Eliseat View Post
Whohooo! My first working code change! (The kids are hungry and I had to make some shopping. But hey, this was more important )
I'm pretty happy right now.
I'm glad to see you got your priorities straight

I looking forward to using these - perhaps I even get a chance to do it this year!


-W
__________________
"if DAWs are religions, REAPER is atheism" - The big J
__________________
Windows 10x64 | Asus Z170-a i7, 32GB ram | RME-Digiface USB
Winfield is offline   Reply With Quote
Old 12-22-2018, 05:15 PM   #8
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Quote:
Originally Posted by EpicSounds View Post
My take on it
Code:
// JT: Essential filled rectangle
// makes a rectangle of any color

//@param1:wet 'opacity' 1.0 0 1 0.5 0.01 
//@param2:R 'Red' 0.5 0 1 0.5 0.01
//@param3:G 'Green' 0.5 0 1 0.5 0.01
//@param4:B 'Blue' 0.5 0 1 0.5 0.01

//@param6:w1 'Width' 50 2 1920 50 2
//@param7:h1 'Height' 50 2 1080 50 2

//@param9:P1 'X position' 50 0 100 50 1
//@param10:P2 'Y position2' 50 0 100 50 1
src=0;
PW=Project_w/100;
PH=Project_h/100;

gfx_blit(0);
gfx_mode=1;
gfx_set(R,G,B,wet);

//line
gfx_gradrect((PW*P1-(w1/2)),(PH*P2-(h1/2)),w1,h1,R,G,B,wet);
Cool. This is also very useful.

Thanks
Eliseat is offline   Reply With Quote
Old 12-30-2018, 07:36 AM   #9
Winfield
Human being with feelings
 
Winfield's Avatar
 
Join Date: Jan 2007
Location: The Underground Bunker
Posts: 705
Default

... 5 characters
__________________
"if DAWs are religions, REAPER is atheism" - The big J
__________________
Windows 10x64 | Asus Z170-a i7, 32GB ram | RME-Digiface USB

Last edited by Winfield; 12-30-2018 at 07:55 AM. Reason: .. wrong thread
Winfield is offline   Reply With Quote
Old 12-30-2018, 11:28 AM   #10
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Quote:
Originally Posted by Winfield View Post
... 5 characters
Eliseat is offline   Reply With Quote
Old 12-30-2018, 11:52 AM   #11
Winfield
Human being with feelings
 
Winfield's Avatar
 
Join Date: Jan 2007
Location: The Underground Bunker
Posts: 705
Default

Quote:
Originally Posted by Eliseat View Post
Yeah I posted something here that was intended for another thread, and there's a 5 character minimum - couldn't delete the post above.

-W
__________________
"if DAWs are religions, REAPER is atheism" - The big J
__________________
Windows 10x64 | Asus Z170-a i7, 32GB ram | RME-Digiface USB
Winfield is offline   Reply With Quote
Old 12-30-2018, 12:02 PM   #12
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by Winfield View Post
Yeah I posted something here that was intended for another thread, and there's a 5 character minimum - couldn't delete the post above.

-W
Edit->Go advanced->Delete messaage->Delete this message
vitalker is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.