Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 04-26-2023, 03:25 AM   #1
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,187
Default JSFX: filled rectangle with rounded edges

I would like to request a function to draw a filled rectangle with rounded edges in gfx. Additionally I would like to ask to revise this function "gfx_roundrect(x,y,w,h,radius[,antialias])" because the rounded edges look very ugly pixelated and are not tangent.
mawi is offline   Reply With Quote
Old 03-18-2024, 03:12 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,989
Default

+1


gfxroundrect seems broken
X-Raym is offline   Reply With Quote
Old 03-18-2024, 03:45 AM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,989
Default




Code:
-- Ultra Basic GFX
-- For quick testing purposes

window_w = 640
window_h = 270

function init(window_w, window_h, window_x, window_y, docked)
  gfx.init("GFX" , window_w, window_h, docked, window_x, window_y)  -- name,w,h,dockstate,xpos,ypos
end

-- DRAW IN GFX WINDOW
function run()
  char = gfx.getchar()
  
  gfx.roundrect(gfx.w / 4, gfx.h / 4, gfx.w / 2, gfx.h / 2, 10, true)
  
  gfx.update()
  if char ~= 27 or char < 0 then reaper.defer(run) else gfx.quit() end

end -- END DEFER

init(window_w, window_h)
run()
It seems the values need rounding before input





Code:
gfx.roundrect( math.floor(gfx.w / 4), math.floor(gfx.h / 4), math.floor(gfx.w / 2), math.floor(gfx.h / 2), 10, true)

But this doesnt solve the fill request.
X-Raym is offline   Reply With Quote
Old 03-18-2024, 08:17 AM   #4
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,187
Default

Thanks for the hint. With floor() the circle lines always remain tangential.
Code:
@gfx 800 500
gfx_set(1);
gfx_roundrect(10, 10, floor(gfx_w/2), floor(gfx_h/2), 20, 1);

Last edited by mawi; 03-18-2024 at 09:01 AM.
mawi is offline   Reply With Quote
Old 03-18-2024, 09:35 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,989
Default

I succceeded to make a workarround, in Lua ReaScript (but could be ported into JSFX)




https://github.com/ReaTeam/ReaScript...th%20alpha.lua


It does support Alpha.






It is of course not as efficient as what would be a native solution, cause it require using other gfx.dest.etc to work.
Too cpu intensive for reatab hero but for static GUI it can work.
X-Raym 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 09:08 AM.


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