View Single Post
Old 12-20-2018, 03:06 PM   #1
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,958
Default preset share - rectangle annotation

Just an empty rectangle with position, thickness, color, opacity.

Needs some optimization to solve occasional 1px overlaps if anyone wants to.

Most of this was done by Robert Randolph / Admiral Bumblebee and I added the color and default settings.

Code:
//RR: Draw box Annotation
//@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:blx 'Bottom Right X' 0.5 0 1 0.5 0.01
//@param4:bly 'Bottom Right Y' 0.5 0 1 0.5 0.01
//@param5:tk  'Thickness' 10 0 50 10 2

//@param7:R 'R' 1 0 1 0.5 0.1
//@param8:G 'G' 1 0 1 0.5 0.1
//@param9:B 'B' 1 0 1 0.5 0.1
//@param10:A 'A' 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);
// convert percentages to pixels
tlxp = tlx * project_w;
blxp = blx * project_w;
tlyp = tly * project_h;
blyp = bly * project_h - tk; // subtrack thickness so we don't go under the frame

// left wall
// X/Y from left
// thickness and height is our bottom left Y
gfx_fillrect(tlxp, tlyp+tk, tk, blyp-(2*tk));

// top wall
// X/Y from left
// width is bottom right X
// height is thickness
gfx_fillrect(tlxp, tlyp, blxp, tk);

// right wall
// X is bottom left minus thickless (to shift it to the left), plus our left X (to offset)
// Y is left Y
// Width is thickness
// Height is bottom left Y
gfx_fillrect(blxp + tlxp-tk, tlyp+tk, tk, blyp-(2*tk));

// bottom wall
// X is top left X
// Y is bottom left Y plus top left Y
// width is bottom left X
// height is thickness
gfx_fillrect(tlxp, blyp + tlyp - tk, blxp, tk);
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog

Last edited by EpicSounds; 12-21-2018 at 02:10 AM.
EpicSounds is offline   Reply With Quote