Old 05-23-2021, 06:33 PM   #1
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default multi-line text overlay

Lets you put a paragraph of text on the screen. Also does colored text. I took out the shadow effect because I never use it and there were too many knobs on the GUI. But if you want to put it back in, just uncomment a few lines and add a param line.

Code:
// overlay multi-line text with colors
// use leading spaces to center text
// use trailing spaces on #text1 to widen the background area
#text1= "put your text here";
#text2= "   line 2";
#text3= "     line 3";
#text4= "       line 4 ";
numLines = 4;               // set to 3 if #text4 is empty
font = "Times New Roman";   //"Times New Roman";  // "Arial"
//@param1:xpos 'x position' 0 0 1 0.5 0.01
//@param2:ypos 'y position' 0 0 1 0.5 0.01
//@param3:size 'text size'  0.05 0.01 0.2 0.1 0.001
//@param4:sp 'line spacing' 1 1 2 1.5 0.1
//@param5:border 'border'   0.3 0 1 0.5 0.01

//@param7:h 'text hue'        1 0 1 0.5 0.01
//@param8:s 'text saturation' 1 0 1 0.5 0.01
//@param9:v 'text lightness'  1 0 1 0.5 0.01
//@param10:a 'text opacity'   1 0 1 0.5 0.01

//@param12:h2 'back hue'        0.5 0 1 0.5 0.01
//@param13:s2 'back saturation' 0.5 0 1 0.5 0.01
//@param14:v2 'back lightness'  0.5 0 1 0.5 0.01
//@param15:a2 'back opacity'    0.5 0 1 0.5 0.01

//@param17:ignoreinput 'ignore input' 0 0 1 0.5 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 = v) : (
  q = v < 0.5 ? v * (1 + s) : v + s - v * s;
  p = 2 * v - q;
  r = hue2rgb(p, q, h + 1/3);
  g = hue2rgb(p, q, h);
  b = hue2rgb(p, q, h - 1/3);
);

s2 == 0 ? (r2 = g2 = b2 = v2) : (
  q = v2 < 0.5 ? v2 * (1 + s2) : v2 + s2 - v2 * s2;
  p = 2 * v2 - q;
  r2 = hue2rgb(p, q, h2 + 1/3);
  g2 = hue2rgb(p, q, h2);
  b2 = hue2rgb(p, q, h2 - 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);
strlen (#text1) == 0 ? input_get_name (-1, #text);
gfx_str_measure (#text1, txtw, txth);
xpos *= project_w - txtw;    // convert from percent to pixels
ypos *= project_h - txth;
brd = border * txth;         // border is a % of the text height
//shd = shadow * txth;       // shadow -- not used in this version
pad = txth / 8;              // extra padding on the sides
sp *= txth;                  // spacing between the lines
gfx_set (r2, g2, b2, a2);    // background
gfx_fillrect (xpos - brd - pad, ypos - brd, 
   txtw + 2*brd + shd + 2*pad, txth + 2*brd + shd + (numLines - 1)*sp);
//gfx_set (0, 0, 0, a);
//gfx_str_draw (#text1, xpos + shd, ypos + shd);   // shadow
gfx_set (r, g, b, a);
gfx_str_draw (#text1, xpos, ypos);
gfx_str_draw (#text2, xpos, ypos + sp);
gfx_str_draw (#text3, xpos, ypos + sp * 2);
gfx_str_draw (#text4, xpos, ypos + sp * 3);
__________________
alt-tuner: a microtonal midi plug-in: www.TallKite.com/alt-tuner.html
The Kite Guitar, a playable 41-ET guitar: www.KiteGuitar.com
Kite is offline   Reply With Quote
Old 06-08-2021, 01:10 AM   #2
Sumalc
Human being with feelings
 
Join Date: Oct 2009
Location: France
Posts: 743
Default

Thank you very much for sharing, it is very useful.
Sumalc is offline   Reply With Quote
Old 06-27-2021, 03:01 AM   #3
CristianoGrassini
Human being with feelings
 
Join Date: Dec 2018
Posts: 11
Default wrap

Hi Kite,
do you know the way to automatically "wrap text" when line i longer than screen?

Thank you
Cristiano
CristianoGrassini is offline   Reply With Quote
Old 06-27-2021, 03:17 AM   #4
enroe
Human being with feelings
 
Join Date: Nov 2017
Posts: 1,575
Default

@Kite: Thank you! The script complements the
video scripts wonderfully!
__________________
free mp3s + info: andy-enroe.de songs and weird stuff: enroe.de
enroe is offline   Reply With Quote
Old 06-28-2021, 06:58 AM   #5
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

Quote:
Originally Posted by CristianoGrassini View Post
do you know the way to automatically "wrap text" when line i longer than screen?
It is possible to modify the code to do this. There would be a lineLength parameter. One would type in a long string, and the code would search for a space character in the string near the end of the line. Then it would break up the string into substrings.

But I personally am not interested in doing that coding. Perhaps someone else here can do that.
__________________
alt-tuner: a microtonal midi plug-in: www.TallKite.com/alt-tuner.html
The Kite Guitar, a playable 41-ET guitar: www.KiteGuitar.com
Kite is offline   Reply With Quote
Old 07-02-2021, 06:32 PM   #6
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

I may have missed something but to my knowledge multi-line text was already possible with this type of syntax:

Code:
// Text overlay
#text="1st   
2nd 
3rd
and many more lines"; // set to string to override
font="Arial";
all you need is to add coloring and styles and you already done it!
papagirafe is offline   Reply With Quote
Old 05-02-2023, 11:37 AM   #7
pietro79
Human being with feelings
 
Join Date: Jun 2016
Posts: 267
Default

But papagirafe, what about leading? Doing it this way, there's no option to space the lines...


Quote:
Originally Posted by papagirafe View Post
I may have missed something but to my knowledge multi-line text was already possible with this type of syntax:

Code:
// Text overlay
#text="1st   
2nd 
3rd
and many more lines"; // set to string to override
font="Arial";
all you need is to add coloring and styles and you already done it!
pietro79 is offline   Reply With Quote
Old 05-02-2023, 06:20 PM   #8
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by pietro79 View Post
But papagirafe, what about leading? Doing it this way, there's no option to space the lines...
I fixed that in my upcoming GiraFX video library. There will be adjustable line spacing, text alignment and much more... patience!
papagirafe 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 04:40 AM.


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