Old 01-16-2017, 08:57 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default API: gfx.arc is 90 degrees off

gfx.arc isn't using the same reference angle as Lua's trig functions. The lines in the image below were drawn using the same angle as the arc's endpoints. As you can see, the arc is 90 degrees away from where it should be.

It's not a difficult thing to fix - just add 0.5 to the rad values when you draw an arc - but it's a prime candidate for the Nitpick forum. If we'd rather not fix it due to the havoc it would wreak on existing scripts, at minimum I'd like to see a note added to the API documentation so nobody else has to waste an hour figuring out why their code was all messed up like I just did.

Cheers.



Code:
local name, w, h = "", 258, 258

local x, y = reaper.GetMousePosition()
x, y = x - (w / 2) - 8, y - (h / 2) - 30

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()
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate

Last edited by Lokasenna; 01-16-2017 at 09:11 PM.
Lokasenna 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 05:30 AM.


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