Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 06-01-2020, 03:56 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,199
Default Text overlay MOD with color, shadow and font type

A modification of the "Overlay: Text" preset.

Adds: HSL sliders, Font slider and Serif slider (total of 16 fonts**), changes behavior of vertical/horizontal position sliders in order to be able to glide the text in-out from screen, shadow sliders and Text Input slider.

Code:
// Text overlay with color/shadow/font type
#text=""; // leave empty to choose input with slider Text Input
type = ''; //'B' - Bold,'I' - Italics,'R' - Blur,'S' - Shadow, 'O' - Outline

// Serif fonts
sans == 1 ? (
  font == 1 ? font="Gabriola";
  font == 2 ? font="Palatino Linotype";
  font == 3 ? font="Comic Sans MS";
  font == 4 ? font="Constantia";
  font == 5 ? font="Times";
  font == 6 ? font="Cambria";
  font == 7 ? font="Georgia";
  font == 8 ? font="Courier";
) : (
// Sans Serif
  font == 1 ? font="Segoe UI";
  font == 2 ? font="Calibri";
  font == 3 ? font="Candara";
  font == 4 ? font="Corbel";
  font == 5 ? font="Tahoma";
  font == 6 ? font="Arial";
  font == 7 ? font="Verdana";
  font == 8 ? font="Consolas";
);

//@param1:size 'text Size' 0.055 0.01 0.4 0.1 0.001
//@param2:font 'text Font' 6 1 8 4 1
//@param3:sans '(sans) Serif' 0 0 1 0.5 1
//@param5:xpos 'Horz position' 0 -1 1 0 0.005
//@param6:ypos 'Vert position' 0 -1 1 0 0.005
//@param8:h 'text Hue' 0 0 1 0.5 0.01
//@param9:s 'text Saturation' 1 0 1 0.5 0.01
//@param10:l 'text Lightness' 1 0 1 0.5 0.01
//@param11:fga 'text Alpha' 1 0 1 0.5 0.01
//@param13:sh 'Horz Shadow' 0 -1 1 0 0.01
//@param14:sh2 'Vert Shadow' 0 -1 1 0 0.01
//@param16:border 'Border Size' 0 0 1 0.5 0.01
//@param17:bgc 'border Brightness' 0.55 0 1 0.5 0.01
//@param18:bga 'border Alpha' 0.5 0 1 0.5 0.01
//@param20:ignoreinput 'Ignore video input' 0 0 1 0.5 1
//@param21:chooseinput 'Text Input' 1 -1 1 0 1

function hue2rgb(p, q, t) (
  t < 0 ? t += 1;
  t > 1 ? t -= 1;
  t < 1/6 ? (
    p + (q - p) * 6 * t;
  ) : (
    t < 1/2 ? (
      q;
    ) : (
      t < 2/3 ? (
        p + (q - p) * (2/3 - t) * 6;
      ) : p;
    );
  );
);

s == 0 ? (
  r = g = b = l;
) : (
  q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  p = 2 * l - q;
  r = hue2rgb(p, q, h + 1/3);
  g = hue2rgb(p, q, h);
  b = hue2rgb(p, q, h - 1/3);
);

input = ignoreinput ? -2:0;
project_wh_valid===0 ? input_info(input,project_w,project_h);
gfx_a2=0;
gfx_blit(input,1);
gfx_setfont(size*project_h,font,type);
strcmp(#text,"")==0 ? input_get_name(chooseinput,#text);
gfx_str_measure(#text,txtw,txth);
gfx_set(bgc,bgc,bgc,bga);
gfx_fillrect(0, (project_h-txth*(1+border*2))/2+ypos*(project_h+txth*(1+border*2))/2,
project_w, txth*(1+border*2));
sh *= txth/10;
sh2 *= txth/10;
// shadow:
gfx_set(0,0,0,fga);
gfx_str_draw(#text,(project_w-txtw)/2+xpos*(project_w+txtw)/2+sh,
(project_h-txth)/2+ypos*(project_h+txth*(1+border*2))/2 + sh2);
// text:
gfx_set(r,g,b,fga);
gfx_str_draw(#text,(project_w-txtw)/2+xpos*(project_w+txtw)/2,
(project_h-txth)/2+ypos*(project_h+txth*(1+border*2))/2);
** Tested on Windows 10

Last edited by amagalma; 06-01-2020 at 09:23 AM.
amagalma is offline   Reply With Quote
Old 06-01-2020, 07:34 AM   #2
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,199
Default

updated code in first post: added a Serif slider. Fonts are grouped into Serif (8 fonts) and Sans Serif (8 fonts)
amagalma is offline   Reply With Quote
Old 06-01-2020, 08:06 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,199
Default

Added a text input slider.
If #text is left empty then it takes the text according to the text input slider.
Use action "Insert dedicated video processor item" to insert items on a track below for subtitles.

Changed behavior of horizontal/vertical position sliders so that text can glide in and out of screen.

Last edited by amagalma; 06-01-2020 at 09:20 AM.
amagalma is offline   Reply With Quote
Old 06-01-2020, 08:39 AM   #4
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,318
Default

Oh amalgama,

I very appreciate your latest efforts in the video section.

I will check the script right now and will give you a feedback. Many thank for the nice contributions here.

Greetings
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 06-01-2020, 09:22 AM   #5
propianist
Human being with feelings
 
Join Date: Feb 2018
Posts: 9
Default

Thank you Amagalma, that's fantastic and very helpful.

Would it be easy for you to include "Vertical out of screen" too please? ie. for classic scrolling end credits at the end of the movie, which needs to disappear off the top and bottoms edge of the screen.

For simplicity...
Why not just have one single param value for horizontal position (and one for vertical position) that covers the entire range from out of screen in each direction, rather than two separate param values governing one property which can be fighting each other? As long as the increments are still small enough, you should still get same absolute full control.

Ani-aliasing to prevent the blocky pixel edges?
Is that what the built-in blur function achieves? I couldn't see it making any visible difference to the blockyness when I entered "R" and updated code. Perhaps blur could be a variable dial parameter instead.

Thank you.
propianist is offline   Reply With Quote
Old 06-01-2020, 09:47 AM   #6
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,318
Default

To create a pool with certain fonts is a nice idea. I just managed to put my own favorites into the variables. Its a very unique approach. Works great. Many thanks.
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 06-02-2020, 08:03 AM   #7
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,199
Default

Quote:
Originally Posted by propianist View Post
Thank you Amagalma, that's fantastic and very helpful.

Would it be easy for you to include "Vertical out of screen" too please? ie. for classic scrolling end credits at the end of the movie, which needs to disappear off the top and bottoms edge of the screen.

For simplicity...
Why not just have one single param value for horizontal position (and one for vertical position) that covers the entire range from out of screen in each direction, rather than two separate param values governing one property which can be fighting each other? As long as the increments are still small enough, you should still get same absolute full control.

Ani-aliasing to prevent the blocky pixel edges?
Is that what the built-in blur function achieves? I couldn't see it making any visible difference to the blockyness when I entered "R" and updated code. Perhaps blur could be a variable dial parameter instead.

Thank you.

Check the code again, because I' ve changed it. No more out-off screen slider. You can do the off-screen/in-screen thing with the xpos and ypos sliders. The only downside is that if you change text size the position of the text changes too. So, first of all you must settle on the font size before doing anything else..

The font anti-aliasing is something that I'd like to do but I have no idea how...

Quote:
Originally Posted by Eliseat View Post
To create a pool with certain fonts is a nice idea. I just managed to put my own favorites into the variables. Its a very unique approach. Works great. Many thanks.
Thanks! I used what is available in Win10 out of the box. But as you did, one can easily change them or make more banks or whatever.
amagalma is offline   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:30 AM.


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