07-03-2020, 04:04 PM | #1 |
Human being with feelings
Join Date: Apr 2010
Location: Portland OR
Posts: 217
|
Overlay rectangle MOD
I got this code from somewhere in this forum, can't remember where. I modded it to work better when midi-learned to mouse dragging. Now you can move the top left and bottom right corners independently. It draws a box (a hollow rectangle). But if you set the thickness to zero, you get a filled rectangle.
Code:
//overlay rectangle // July 3 2020 TallKite Software // midi-learn tlx/tly to drag-X/Y, brx/bry to control-drag-X/Y // zero thickness means fill the box //@param1:tlx 'Top left X' 0.25 0 1 0.5 0.01 //@param2:tly 'Top left Y' 0.25 0 1 0.5 0.01 //@param3:brx 'Bottom right X' 0.75 0 1 0.5 0.01 //@param4:bry 'Bottom right Y' 0.75 0 1 0.5 0.01 //@param5:tk 'Thickness (0 = fill)' 10 0 50 25 2 //@param7:R 'Red' 1 0 1 0.5 0.1 //@param8:G 'Green' 1 0 1 0.5 0.1 //@param9:B 'Blue' 1 0 1 0.5 0.1 //@param10:A 'Opacity' 1 0 1 0.5 0.01 input = 0; !project_wh_valid && input_info(input,w,h) ? ( project_w=w; project_h=h); input = 0; gfx_blit(input,1); gfx_set(R,G,B,A); tlx = tlx * project_w; // convert percentages to pixels brx = brx * project_w; tly = tly * project_h; bry = bry * project_h; brx < tlx ? (t=tlx; tlx=brx; brx=t); // swap corners bry < tly ? (t=tly; tly=bry; bry=t); //brx < tlx + tk ? brx = tlx + tk; // stay in range //bry < tly + tk ? bry = tly + tk; // (alternate way) tk == 0 ? gfx_fillrect (tlx, tly, brx-tlx, bry-tly) : ( gfx_fillrect (tlx, tly, tk, bry-tly); // left wall gfx_fillrect (tlx, tly, brx-tlx, tk); // top wall gfx_fillrect (brx-tk, tly, tk, bry-tly); // right wall gfx_fillrect (tlx, bry - tk, brx-tlx, tk); // bottom wall );
__________________
alt-tuner: a microtonal midi plug-in: www.TallKite.com/alt-tuner.html The Kite Guitar, a playable 41-ET guitar: www.KiteGuitar.com Last edited by Kite; 07-08-2020 at 08:21 PM. |
07-04-2020, 03:02 AM | #2 |
Human being with feelings
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
|
Ah, I see you fixed the glitching gaps by overlapping the lines at the corners. The original code - if I'm right - is from Jon. But he struggled by the problem, that moving and zooming objects can't get done smoothly in Reaper. Only in little jumps which made the rectangle flickering and opening at the corners. Its a big problem for zooming and panning still images too. I hope this gets fixed someday, because it makes many applications useless from the start.
But many thanks. Your version works very nice. Greetings
__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
|
Thread Tools | |
Display Modes | |
|
|