Prev Previous Post   Next Post Next
Old 02-07-2010, 09:29 AM
bzdbbb's Avatar
bzdbbb bzdbbb is offline
X-Fi2 Development Moderator
Join Date: Dec 2009
Location: Gloucestershire, UK
Posts: 94
Page Common Code Fragments

Now that the SKD has been released and more people are getting into writing apps I thought it would be a good idea to have a thread devoted to useful reusable code functions that are not included in the standard Libraries.

I'll kick things off; :P

Returns true if the point x,y is within the region at rx,ry with the width w and height h, else returns false:
function withinRegion(x, y, rx, ry, w, h)

	if x >= rx and x <= (rx + w) and y >= ry and y <= (ry + h) then
		return true;
		return false;

Returns the distance in pixels between x,y and x1,y1
function pointDistance(x,y,x1,y1)
	local xdist;
	local ydist;
	local dist;
	xdist = math.abs(x-x1);
	ydist = math.abs(y-y1);
	dist = math.sqrt((xdist*xdist)+(ydist*ydist));
	return dist;
If you've written any other useful functions or have a improvement to one already listed, please post
Reply With Quote

Advertisement [Remove Advertisement]


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 -5. The time now is 03:41 PM.