View Single Post
Old 12-21-2018, 04:36 AM   #4
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 115
Default

Cool thank you for sharing!
Those gaps could be rounding issues (again). See if this helps Eli. It rounds/floors to even indices because of this. If you find that step size too coarse just change all "&-2" parts to "|0" which just floors.
PHP 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=wproject_h=h; );

input 0;
gfx_blit(input,1);
gfx_set(R,G,B,A);
// convert percentages to pixels
tlxp = (tlx project_w)&-2;  // &-2 <-- floor to even indices, see https://forum.cockos.com/showthread.php?p=2072268#post2072268
blxp = (blx project_w)&-2;
tlyp = (tly project_h)&-2;
blyp = (bly project_h tk)&-2// 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(tlxptlyp+tktkblyp-(2*tk));

// top wall
// X/Y from left
// width is bottom right X
// height is thickness
gfx_fillrect(tlxptlypblxptk);

// 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-tktlyp+tktkblyp-(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(tlxpblyp tlyp tkblxptk); 
wwwmaze is offline   Reply With Quote