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

Reply
 
Thread Tools Display Modes
Old 06-25-2020, 06:29 PM   #1
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default Image overlay with rotation, for drawing lines and circles on top of a video

I'm making a video with a lot of subtitles and diagrams. I want to have the ability to circle things, draw lines connecting things, etc. It seems you can't use gfx_circle or gfx_line in the video processor. So I figured out a way to do it using image overlays. It's pretty clunky, so if any one can think of an easier way, please share!

For circles, run a draw program and draw an empty (unfilled) circle. Then save it as a png file with a transparent background. Then use the usual image overlay preset. But you can't control the color, so I had to make 3 png images, a red circle, a black circle and a white circle. You can control the size of the circle with the zoom parameter. But the circle thickens up as it gets bigger. So I'll probably make bigRedCircle.png, smallWhiteCircle.png, etc.

Lines work the same way, make longRedLine.png, shortBlackLine.png, etc. and overlay them. Or a long line can be two overlapping short lines. But I want to be able to draw lines at an angle. So I modded the image overlay effect to add rotation. I used gfx_rotoblit, which unfortunately can distort the images. My workaround was to make the png files perfectly square.

This page https://mespotin.uber.space/Ultrasch...l#gfx_rotoblit says that you can use gfx_deltablit to get around this distortion problem. But it looks much more complicated. Is gfx_deltablit documented better somewhere?

Code:
//Image overlay with rotation
//@param1:opacity 'opacity' 1
//@param2:zoom 'zoom' 0 -15 15 0
//@param3:xoffs 'X offset' 0 -1 1 0
//@param4:yoffs 'Y offset' 0 -1 1 0
//@param5:angle 'angle' 0 -90 90 0 5
//@param6:filter 'filter' 0 0 1 0.5 1
//@param7:use_srca 'alpha channel' 1 0 1 0.5 1
// image must be square, or it gets distorted

img1=input_track(0);
img2=0;
use_srca && img2 != img1 ? colorspace='RGBA';
input_info(img1,img1w,img1h) && project_wh_valid===0 ?  ( project_w = img1w; project_h = img1h; );

a = opacity < 0.01 ? 0 : opacity > 0.99 ? 1 : opacity;

img2 != img1 && input_info(img2,sw,sh) ? (
  gfx_blit(img1,0);
  a>0?(
    gfx_a=a;
    gfx_mode = (filter>0.5 ? 256 : 0)|(use_srca?0x10000:0);
    z = 10^(zoom/10);
    dw = (sw*z)|0;
    dh = (sh*z)|0;
    x = (project_w - dw + (project_w + dw)*xoffs)*.5;
    y = (project_h - dh + (project_h + dh)*yoffs)*.5;
    gfx_rotoblit(img2,0.01745329252*angle, x|0,y|0,dw,dh);
  );
);
Attached Images
File Type: png black circle.png (9.4 KB, 194 views)
File Type: png black line.png (4.0 KB, 170 views)
File Type: png red line.png (4.0 KB, 196 views)
File Type: png white circle.png (8.0 KB, 171 views)
File Type: png white line.png (4.0 KB, 170 views)
__________________
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-27-2020, 04:30 AM   #2
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

To circle something you could use this. Its not perfect but offers some options to bend a line into a circle.
https://forum.cockos.com/showthread.php?t=237528

Greetings
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 06-30-2020, 02:26 PM   #3
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

Thanks Eli, but your effect doesn't solve the problem of the circle thickening up when you make it bigger. (IOW the line thickness isn't independent of the size of the circle.)
__________________
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-30-2020, 03:33 PM   #4
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

One can use gfx_drawrect to draw a horizontal or vertical line of any length, thickness and color. Is it possible to then somehow rotate it using gfx_rotoblit or gfx_deltablit?
__________________
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-01-2020, 10:43 AM   #5
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Quote:
Originally Posted by Kite View Post
One can use gfx_drawrect to draw a horizontal or vertical line of any length, thickness and color. Is it possible to then somehow rotate it using gfx_rotoblit or gfx_deltablit?
If you want to create kind of a circle maker then you could take a closer look to the preset I posted above. If I remember right it was originally created by wwwmaze with the intention to get a half circle. I just managed to change the code to make a "real" circle.

Theoretically you could take the code and draw a vertical or horizontal line as you suggested before the "circling" and make its background transparent. This would create circles of all kinds, colors and thicknesses. But I have no idea, how to write something like that.

greetings
Eli
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat is offline   Reply With Quote
Old 07-01-2020, 06:03 PM   #6
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

I suppose I'd have to draw to a buffer, then blit the buffer to the video. Does anyone know how to use buffers
__________________
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-2020, 02:37 AM   #7
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Also interesting for you could be the vignette preset from Justin which gets shipped with Reaper. It shows a black surrounding what lets the background video thru inside of the circle. If I understand the code right, it draws many rectangles in a circle to create the illusion of circle. Maybe there you could find the needed hint of how to buffer things.

By the way. I'm happy to see someone new in the video section who codes for the video processor. Most people here feel like Christmas every time someone posts an new preset. Many thanks.

Greetings
ELi
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat 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 08:05 AM.


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