Reusing code from the other nitpick thread I just posted, but whatever.
reaper.GetMousePosition is returning a point slightly to the right and a full cursor down from where my mouse cursor's point actually is. The code below should open with the window centered on the cursor (center being where the two lines meet), but as you can see:
Whoops? I think it's just not taking the window frame into account, but from what I can tell the only way to get proper coordinates in that sense is to query
gfx.dock, which isn't available until after the window opens, which would necessitate quitting and reopening the window. Seems a bit much.
Code:
local name, w, h = "", 258, 258
local x, y = reaper.GetMousePosition()
x, y = x - (w / 2), y - (h / 2)
local ox, oy = w / 2, h / 2
local angle_a = -0.25 * math.pi
local angle_b = 0.25 * math.pi
local r = 96
function Main()
local quit = gfx.getchar()
if quit == -1 or quit == 27 then return 0 end
gfx.set(0.2, 1, 0.2, 1)
local ax = ox + r * math.cos(angle_a)
local ay = oy + r * math.sin(angle_a)
gfx.line(ox, oy, ax, ay)
local bx = ox + r * math.cos(angle_b)
local by = oy + r * math.sin(angle_b)
gfx.line(ox, oy, bx, by)
gfx.set(1, 0.2, 0.2, 1)
gfx.arc(ox, oy, r, angle_a, angle_b, 1)
reaper.defer(Main)
gfx.update()
end
gfx.init(name, w, h, 0, x, y)
Main()